Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

Sstr = input()
stop=len(Sstr)
count=0
for i in range(stop-3):
    for j in range(i,stop):
        if(int(Sstr[i:j+1])%2019==0):
            count=count+1
print(count)

### FIXED CODE ###

p = 2019 
D = input()
n=(len(D))
out = 0


if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    mod = 0
    count = [0] * p
    ten = 1
    count[mod] += 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        ten = ten * 10 % p
        count[mod] += 1
    for c in count:
        out += (c * (c - 1)) // 2
print(out)
### BUGGY CODE ###

from heapq import heappush, heappop

N, M = map(int, input().split())

list = [list(map(int, input().split())) for _ in range(N)]


list.sort(key = lambda x: x[0])

ans = 0
heap = []
for day in range(1,M+1):
	for i in list:		
		if i[0] == day:
			heappush(heap, -i[1])
		elif i[0] > day:
			break
    
	if len(heap) > 0:
		ans += -heappop(heap)

print(ans)

### FIXED CODE ###

from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)
### BUGGY CODE ###

import math

K = int(input())
result = 0
sum = 0




for a in range(1,K+1):
    for b in range(1,K+1):
        result = math.gcd(a, b)
        for c in range(1,K+1):
            result = math.gcd(a, b)
            sum += math.gcd(result, c)

print(sum)            


### FIXED CODE ###

K = int(input())
import math
sum=0
for i in range(1, K+1):
    for j in range(1, K+1):
        value = math.gcd(i,j)
        for k in range(1, K+1):
            sum += math.gcd(value,k)
 
print(sum)
### BUGGY CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

h, w, k = map(int, input().split())
memo = defaultdict(lambda:defaultdict(int))

def dfs(x, y):
    if y == h:
        if x == k - 1:
            return 1
        else:
            return 0
    if memo[x][y]:
        return memo[x][y]
#    if y in memo[x]:
#        return memo[x][y]

    ans = 0
    for i in range(1 << w - 1):
        flg = True
        for j in range(w - 2):
            if i & (1 << j) and i & (1 << j + 1):
                flg = False
                break
        if flg:
            nx = x
            if x > 0 and i & (1 << x - 1):
                nx = x - 1
            elif i & (1 << x):
                nx = x + 1
            ans += dfs(nx, y + 1)
            ans %= 1000000000 + 7
    memo[x][y] = ans
    return ans
print(dfs(0, 0))


### FIXED CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

h, w, k = map(int, input().split())
memo = defaultdict(lambda:defaultdict(int))

def dfs(x, y):
    if y == h:
        if x == k - 1:
            return 1
        else:
            return 0
    if y in memo[x]:
        return memo[x][y]

    ans = 0
    for i in range(1 << w - 1):
        flg = True
        for j in range(w - 2):
            if i & (1 << j) and i & (1 << j + 1):
                flg = False
                break
        if flg:
            nx = x
            if x > 0 and i & (1 << x - 1):
                nx = x - 1
            elif i & (1 << x):
                nx = x + 1
            ans += dfs(nx, y + 1)
            ans %= 1000000000 + 7
    memo[x][y] = ans
    return ans
print(dfs(0, 0))
### BUGGY CODE ###

# -*- coding: utf-8 -*-

from heapq import heappop, heappush
    

def resolve(T,v):
    while v != T[v]:
        v = T[v]
    return v

def solve():
    N, M = map(int, input().split())
    E = set()
    for _ in range(M):
        a, b = map(int, input().split())
        E.add((a-1,b-1))

    T = list(range(N))
    while E:
        e = E.pop()
        u, v = e
        lu = resolve(T,u)
        lv = resolve(T,v)
        if lv == lu:
            continue
        T[lu] = lv
        continue

    return len(set(resolve(T,v) for v in range(N)))-1

if __name__ == '__main__':
    print(solve())



### FIXED CODE ###

# -*- coding: utf-8 -*-

def resolve(T,v):
    lv = v
    while lv != T[lv]:
        lv = T[lv]
    T[v] = lv
    return lv

def solve():
    N, M = map(int, input().split())
    T = list(range(N+1))
    for i in range(M):
        u, v = map(int, input().split())
        lu = resolve(T,u)
        lv = resolve(T,v)
        if lv == lu:
            continue
        T[lv] = lu
        #print(f'===round{i}===')
        #print(T)
        #print([resolve(T,v) for v in range(N+1)])
    return len(set(resolve(T,v) for v in range(1,N+1)))-1

if __name__ == '__main__':
    print(solve())
### BUGGY CODE ###

from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = input()
    if command[0] == "i":
        que.appendleft(command[7:])
    elif "deleteFirst" in command:
        que.popleft()
    elif "deleteLast" in command:
        que.pop()
    else:
        try:
            que.remove(command[7:])
        except:
            pass
print(*que)

### FIXED CODE ###

import sys
from collections import deque

n = int(input())
que = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)
### BUGGY CODE ###

n = int(input())
i = 0
A = []
while i < n:
	A.append(int(input()))
	i += 1
	
for i in range(len(A)):
	m = max(A)
	if A[i] == m:
		A1 = A.copy()
		del A1[i]
		print(max(A1))
	else:
		print(max(A))

### FIXED CODE ###

n = int(input())
A = []
for i in range(n):
	A.append(int(input()))
	
B = A.copy()
B.remove(max(B))

A_max = max(A)
B_max = max(B)

for i in range(n):
	if A[i] == A_max:
		print(B_max)
	else:
		print(A_max)
### BUGGY CODE ###

from sys import stdin
readline = stdin.readline

R, C, K = map(int, readline().split())

goods = [[0] * C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, readline().split())
    goods[r - 1][c - 1] = v

n = [0] * (C + 1)
for i in range(R):
    c = [0] * 4
    c[0] = n[0]
    for j in range(C):
        if goods[i][j] != 0:
            for k in range(2, -1, -1):
                if c[k] + goods[i][j] > c[k + 1]:
                    c[k + 1] = c[k] + goods[i][j]
        for k in range(4):
            if c[k] > n[j]:
                n[j] = c[k]
        if n[j + 1] > c[0]:
            c[0] = n[j + 1]

print(max(c))


### FIXED CODE ###

from sys import stdin
readline = stdin.readline

R, C, K = map(int, readline().split())

goods = [[0] * C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, readline().split())
    goods[r - 1][c - 1] = v

n = [0] * (C + 1)
for i in range(R):
    c = [0] * 4
    c[0] = n[0]
    for j in range(C):
        if goods[i][j] != 0:
            for k in range(2, -1, -1):
                if c[k] + goods[i][j] > c[k + 1]:
                    c[k + 1] = c[k] + goods[i][j]
        for k in range(4):
            if c[k] > n[j]:
                n[j] = c[k]
        if n[j + 1] > c[0]:
            c[0] = n[j + 1]

print(max(c))
### BUGGY CODE ###

A,B,C,D=map(int,input().split())
mod=998244353
dp=[[0]*(C-A+1) for _ in range(D-B+1)]
dp[0][0]=1
for i in range(1,D-B+1):
	dp[i][0]=dp[i-1][0]*A%mod
for j in range(1,C-A+1):
	dp[0][j]=dp[0][j-1]*B%mod
for i in range(1,D-B+1):
	for j in range(1,C-A+1):
		dp[i][j]+=(dp[i-1][j]*(A+j)+dp[i][j-1]*(B+i)-((B+i-1)*(A+j-1))*dp[i-1][j-1]+mod)%mod
print(dp[-1][-1])

### FIXED CODE ###

A,B,C,D=map(int,input().split())
mod=998244353
dp=[[0]*(C-A+1) for _ in range(D-B+1)]
dp[0][0]=1
for i in range(1,D-B+1):
	dp[i][0]=dp[i-1][0]*A%mod
for j in range(1,C-A+1):
	dp[0][j]=dp[0][j-1]*B%mod
for i in range(1,D-B+1):
	for j in range(1,C-A+1):
		dp[i][j]+=(dp[i-1][j]*(A+j)+dp[i][j-1]*(B+i)-((B+i-1)*(A+j-1))*dp[i-1][j-1]+mod)%mod
print(dp[-1][-1])
### BUGGY CODE ###

# /user/bin/python
# -*- coding: utf-8 -*-
import sys 


## input
N = int(sys.stdin.readline().rstrip())
An = [0] + list(map(int, sys.stdin.readline().rstrip().split()))
sum = [0] * (N+1)
for i in range(1, N+1):
  sum[i] = sum[i-1] + An[i]

ans = sys.maxsize
for i in range(2, N-1):
  ## Split BC
  left, right = 1, i
  while(right-left > 1):
    mid = (left + right) // 2
    sum_l = sum[mid]
    sum_r = sum[i] - sum[mid]
    if sum_l > sum_r:
      left, right = left, mid
    else:
      left, right = mid, right

  P1,Q1 = sum[left], sum[i] - sum[left]
  P2,Q2 = sum[right], sum[i] - sum[right]
  if abs(P1-Q1) >= abs(P2-Q2):
    P,Q = P2, Q2
  else:
    P,Q = P1, Q1

  ## Split DE
  left, right = i+1, N
  while(right-left > 1):
    mid = (left + right) // 2
    sum_l = sum[mid] - sum[i]
    sum_r = sum[N] - sum[mid]
    if sum_l > sum_r:
      left, right = left, mid
    else:
      left, right = mid, right

  R1,S1 = sum[left]-sum[i], sum[N]-sum[left]
  R2,S2 = sum[left+1]-sum[i], sum[N]-sum[left+1]
  if abs(R1-S1) >= abs(R2-S2):
    R,S = R2, S2
  else:
    R,S = R1, S1

  ans = min(ans, max(P,Q,R,S) - min(P,Q,R,S))

print(ans)

### FIXED CODE ###

# /user/bin/python
# -*- coding: utf-8 -*-
import sys 
from itertools import accumulate


def diff(p,q,r,s):
  return abs(max(p,q,r,s) - min(p,q,r,s))


## input
N = int(sys.stdin.readline().rstrip())
An = [0] + list(map(int, sys.stdin.readline().rstrip().split()))
sum = list(accumulate(An))


ans = sys.maxsize
li,ri = 1, 3
for i in range(2, N-1):
  while sum[li] < sum[i]-sum[li]:
    li += 1
  while sum[ri]-sum[i] < sum[N]-sum[ri]:
    ri += 1

  P1,Q1 = sum[li], sum[i]-sum[li]
  P2,Q2 = sum[li-1], sum[i]-sum[li-1]
  R1,S1 = sum[ri]-sum[i], sum[N]-sum[ri]
  R2,S2 = sum[ri-1]-sum[i], sum[N]-sum[ri-1]

  ans = min(ans, diff(P1,Q1,R1,S1), diff(P1,Q1,R2,S2), diff(P2,Q2,R1,S1), diff(P2,Q2,R2,S2))

print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
V = list(map(int, input().split()))

rs = []
def check(k, v, current):
	global rs
	rs += [sum(current)]
	if 0 == k:
		return
	else:
		if current:
			mc = min(current)
			if mc < 0:
				i = current.index(mc)
				check(k - 1, v + [mc], current[:i] + current[i + 1:])
				check(k - 1, [mc] + v, current[:i] + current[i + 1:])
		if v:
			check(k - 1, v[1:], current + [v[0]])
			check(k - 1, v[:-1], current + [v[-1]])
		return

check(K, V, [])

print(max(rs))


### FIXED CODE ###

N, K = map(int, input().split())
V = list(map(int, input().split()))

vmax = 0
for l in range(0, K + 1):
	for r in range(0, K - l + 1):
		if N < l + r:
			break
		tv = V[:l] + V[N - r:]
		#print(tv)
		tv.sort()
		for n in range(min(len(tv), K - (l + r))):
			if tv[n] < 0:
				tv[n] = 0
		vmax = max(vmax, sum(tv))

print(vmax)
### BUGGY CODE ###

s = input()
n = int(input())

h = 0
for i in range(n):
    qq = list(input().split())
    if qq[0] == '1':
        h += 1
    else:
        if qq[1] == '1':
            if h % 2 ==1:
                s = s + qq[2]
            else:
                s = qq[2] + s
        else:
            if h % 2 ==1:
                s = qq[2] + s
            else:
                s = s + qq[2]

if h % 2 ==1:
    s = s[::-1]
print(s)

### FIXED CODE ###

s = input()
n = int(input())
b = ''
a = ''
h = 0
for i in range(n):
    qq = list(input().split())
    if qq[0] == '1':
        h += 1
    else:
        if qq[1] == '1':
            if h % 2 ==1:
                a = a + qq[2]
            else:
                b = qq[2] + b
        else:
            if h % 2 ==1:
                b = qq[2] + b
            else:
                a = a + qq[2]

s = b + s + a
if h % 2 ==1:
    s = s[::-1]
print(s)
### BUGGY CODE ###

from sys import stdin
def main():
    n = int(stdin.readline().rstrip())
    a = list(map(int,stdin.readline().rstrip().split()))
    mod = 10**9+7
    point = 0
    kai = [2**i%mod for i in range(61)]
    for i in range(61):
        now = (sum(1 for j in a if(j >> i)&1))
        point += now*(n-now)*kai[i]%mod
    print(point%mod)
if __name__ == "__main__":
    main()

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
point = 0
for i in range(61):
    now = 0
    for j in a:
        now += (j >> i&1)
    now *= n-now
    now %= mod
    for k in range(i):
        now *= 2
        now %= mod
    point += now
    point %= mod
print(point)
### BUGGY CODE ###

from collections import deque


S = deque(input())
Q = int(input())

for _ in range(Q):
    Query = input().split()
    if Query[0] == "1":
        S = deque(reversed(S))
    else:
        F, C = Query[1], Query[2]
        if F == "1":
            S.appendleft(C)
        else:
            S.append(C)

print("".join(S))


### FIXED CODE ###

from collections import deque


S = deque(input())
Q = int(input())
reverse_count = 0

for _ in range(Q):
    Query = input().split()
    if Query[0] == "1":
        reverse_count += 1
    else:
        F, C = Query[1], Query[2]
        if F == "1":
            if reverse_count % 2 == 0:
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if reverse_count % 2 == 0:
                S.append(C)
            else:
                S.appendleft(C)

if reverse_count % 2 == 1:
    S.reverse()
print("".join(S))
### BUGGY CODE ###

K = int(input())
nana = "7"
kou = 1
if K % 2 == 0:
    print(-1)
else:
    while True:
        if int(nana) % K == 0:
            break
        nana += '7'
        kou+=1
    print(kou)


### FIXED CODE ###

K = int(input())
nana=7
kou=1
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    for i in range(1,K):
        if nana % K == 0:
            break
        nana = (nana * 10 + 7) % K
        kou +=1
    print(kou)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

N, M, K = map(int, input().split())
G = [[] for _ in range(N)]
AB = []
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    AB.append((a-1, b-1))

H = [[] for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    H[c-1].append(d-1)
    H[d-1].append(c-1)

seen = [0]*N
def dfs(v):
    seen[v] = 1
    ret = [v]
    for u in G[v]:
        if seen[u] == 1: continue
        ret += dfs(u)
    return ret

num = [0]*N
for v in range(N):
    if seen[v] == 1: continue
    new = dfs(v)
    size = len(new)
    for n in new:
        num[n] = len(set(new) - set(H[n]) - set(G[n])) - 1
    
print(' '.join(map(str, num)))



### FIXED CODE ###

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]


N, M, K = map(int, input().split())

#初期化
#根なら-size,子なら親の頂点
par = [-1]*N

G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    unite(a-1, b-1)

ans = [size(v) - len(G[v]) - 1 for v in range(N)]

H = [[] for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    if same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
    
print(' '.join(map(str, ans)))
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():

    class BinaryIndexedTree:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)
    
        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s
    
        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

    N = int(input())
    S = list(input())
    Q = int(input())
    Query = [input().split() for _ in range(Q)] 

    pos_bit_list = [BinaryIndexedTree(len(S)) for _ in range(26)]

    for i, c in enumerate(S):
        pos_bit_list[ord(c)-ord('a')].add(i+1, 1)

    for q in Query:
        if q[0] == '1':
            i = int(q[1])
            c = q[2]
            pos_bit_list[ord(S[i-1])-ord('a')].add(i, -1)
            pos_bit_list[ord(c)-ord('a')].add(i, 1)
            S[i-1] = c
        else:
            print(len([p for p in pos_bit_list if p.sum(int(q[2])) - p.sum(int(q[1])-1) > 0]))

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():

    class BinaryIndexedTree():
        def __init__(self, n):
            self.n = n
            self.bit = [0]*(n+1)

        def add(self, item, pos):
            index = pos
            while index < self.n+1:
                self.bit[index] += item
                index += index & (-index)

        def sum(self, pos):
            ret = 0
            index = pos
            while index > 0:
                ret += self.bit[index]
                index -= index & -index
            return ret

    N = int(input())
    S = list(input())
    Q = int(input())
    Query = [input().split() for _ in range(Q)] 

    pos_bit_list = [BinaryIndexedTree(len(S)) for _ in range(26)]

    for i, c in enumerate(S):
        pos_bit_list[ord(c)-ord('a')].add(1, i+1)

    for q in Query:
        if q[0] == '1':
            pos_bit_list[ord(S[int(q[1])-1])-ord('a')].add(-1, int(q[1]))
            pos_bit_list[ord(q[2])-ord('a')].add(1, int(q[1]))
            S[int(q[1])-1] = q[2]
        else:
            print(len([p for p in pos_bit_list if p.sum(int(q[2])) - p.sum(int(q[1])-1) > 0]))

if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

def cover(V, i):
    for j in range(i + 1, len(V)):
        if V[i] & V[j]:
            V.append(V[i] | V[j])
            del V[j], V[i]
            return True

n, m = map(int, raw_input().split())
V = []
for _ in range(m):
    v = set(map(int, raw_input().split()))
    V.append(v)

flag = True
while flag:
    flag = False
    for i in range(len(V)):
        if cover(V, i):
            flag = True
            break

q = int(raw_input())
for _ in range(q):
    s, t = map(int, raw_input().split())
    flag = True
    for v in V:
        if s in v:
            if t in v:
                print "yes"
            else:
                print "no"
            flag = False
            break
    if flag:
        print "no"

### FIXED CODE ###

def bfs(i, c):
    global V, C

    q = [i]
    while len(q) > 0:
        j = q.pop()
        if C[j] == -1:
            C[j] = c
            q += V[j]

n, m = map(int, raw_input().split())
V = [[] for _ in range(n)]
C = [-1] * n
for _ in range(m):
    l, r = map(int, raw_input().split())
    V[l].append(r)
    V[r].append(l)

c = 0
for i in range(n):
    if C[i] == -1:
        bfs(i, c)
        c += 1

q = int(raw_input())
for _ in range(q):
    s, t = map(int, raw_input().split())
    if C[s] == C[t]:
        print "yes"
    else:
        print "no"
### BUGGY CODE ###

H,W = map(int,input().split())
S = [input() for i in range(H)]

rs = [[0]*W for i in range(H)]
ls = [[0]*W for i in range(H)]
ds = [[0]*W for i in range(H)]
us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            rs[i][j] = tmp
    tmp = 0
    for j in reversed(range(W)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ls[i][j] = tmp

for j in range(W):
    tmp = 0
    for i in range(H):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ds[i][j] = tmp
    tmp = 0
    for i in reversed(range(H)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            us[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        tmp = rs[i][j] + ls[i][j] + ds[i][j] + us[i][j] - 3
        ans = max(ans, tmp)
print(ans)


### FIXED CODE ###

H,W = map(int,input().split())
S = [input() for i in range(H)]

rs = [[0]*W for i in range(H)]
ls = [[0]*W for i in range(H)]
ds = [[0]*W for i in range(H)]
us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            rs[i][j] = tmp
    tmp = 0
    for j in reversed(range(W)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ls[i][j] = tmp

for j in range(W):
    tmp = 0
    for i in range(H):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ds[i][j] = tmp
    tmp = 0
    for i in reversed(range(H)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            us[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        tmp = rs[i][j] + ls[i][j] + ds[i][j] + us[i][j] - 3
        ans = max(ans, tmp)
print(ans)
### BUGGY CODE ###

N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'
for i in range(N):
  for j in range(i):
    if H[i] < H[j]-1:
      ans = 'No'
      
print(ans)

  

### FIXED CODE ###

n = int(input())
 
h = list(map(int,input().split()))
 
height = h[0]
 
q = 0
 
for i in h:
    if i < height:
        q = 1
        break
    elif i > height:
        height = i-1
    else:
        height = i
        
if q == 1:
    print("No")
else:
    print("Yes")
### BUGGY CODE ###

def main():
    N = int(input())
    S = input()
    ans = N

    for i in range(N):
        cnt = S[:i].count("W") + S[i + 1:].count("E")
        if cnt < ans:
            ans = cnt

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    S = input()
    lst = [0] * N
    ans = N

    if S[0] == "E":
        lst[0] = 1
    for i in range(1, N):
        if S[i] == "E":
            lst[i] = lst[i - 1] + 1
        else:
            lst[i] = lst[i - 1]

    for i in range(N):
        if i == 0:
            left = 0
        else:
            left = i - lst[i - 1]
        right = lst[N - 1] - lst[i]

        if left + right < ans:
            ans = left + right

    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

if __name__ == '__main__':
    n = int(input().strip())
    A = list(map(int, input().strip().split()))
    A.sort(reverse=True)
    score = 0
    if not len(A) < 2:
        min_max_list = [A[1], A[1]]
        score = A[0]
        for a in A[2:]:
            arg_max_index = min_max_list.index(max(min_max_list))
            score += min_max_list[arg_max_index]
            min_max_list[arg_max_index] = a
            min_max_list.insert(arg_max_index, a)
    print(score)


### FIXED CODE ###

if __name__ == '__main__':
    n = int(input().strip())
    A = list(map(int, input().strip().split()))
    A.sort(reverse=True)

    score = A[0] + sum([A[1+int(i/2)]for i in range(0, n-2)])

    print(score)