Harryxun/stf_run huggingface dataset:
N,M=map(int,input().split())
    
ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[iii]==True:
        Wsum=Wsum+WACNT[iii]

print(Asum,Wsum)

### FIXED CODE ###

N,M=map(int,input().split())
    
if M==0 :
    print(0,0)
    exit()

ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[i]==True:
        Wsum=Wsum+WACNT[i]

print(Asum,Wsum)
N, Y = map(int, input().split())

answer = '-1 -1 -1'
for x in range(0,N+1):
    for y in range(0,N+1):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and x + y + z == N and z >= 0:
            answer = f'{x} {y} {z}'
            break
    else:
        continue
    break
print(answer)





### FIXED CODE ###

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

answer = '-1 -1 -1'
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and z >= 0:
            answer = str(x) + ' ' + str(y) + ' ' + str(z) 
            break
print(answer)
n=int(input())
a=[]
b=[]
for i in range(n):
    tmpa,tmpb = map(int,input().split())
    a.append(tmpa)
    b.append(tmpb)

a.sort()
b.sort()

if n%2==1:
    print(b[n//2] - a[n//2] +1)
else:
    print((b[n//2+2]-b[n//2+1]) - (a[n//2+2]-a[n//2+1]) +1)


### FIXED CODE ###


n=int(input())
a=[]
b=[]
for i in range(n):
    tmpa,tmpb = map(int,input().split())
    a.append(tmpa)
    b.append(tmpb)

a.sort()
b.sort()

if n%2==1:
    print(b[n//2] - a[n//2] +1)
else:
    print((b[n//2]+b[n//2-1]) - (a[n//2]+a[n//2-1]) +1)
s=input()
ans=0
for i in range(0,3):
  if s[i]=s[i+1]:
    ans+=1
  else:
    ans+=0

if ans==0:
  print("Good")
else:
  print("Bad")

### FIXED CODE ###

s=input()
ans=0
for i in range(0,3):
  if s[i]==s[i+1]:
    ans+=1
  else:
    ans+=0

if ans==0:
  print("Good")
else:
  print("Bad")
n = int(input())
lst = range(2, n)

divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i-1)
        if i != n // i:
            divisors.append(n//i-1)

divisors.pop(0)
divisors.pop(1)
print(sum(divisors))

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())

    def yakusu():
        for i in range(1, int(n**0.5)+1):
            if n%i == 0:
                yield i
                if i != n //i:
                    yield n//i

    for m in yakusu():
        m -= 1
        if m == 0:
            continue

        if n // m == n % m:
            yield m

print(sum(main()))
#C
import numpy as np
flg = True
n,m,x = map(int,input().split())
algo = []
for _ in range(n):
    algo.append(list(map(int,input().split())))
    

algo_n = np.array(algo)
algo_sum = algo_n.sum(axis=0)
gokei = algo_sum.tolist()
money = gokei[0]
gokei = gokei[1:]

#チェックする
for i in range(m):
    if gokei[i] < x:
        flg = False
        print(-1)
        break

algo.sort(key= lambda x:x[0],reverse=True)

#print(algo)
#print(gokei)
# 計算用の関数
def hikizan(lst1,lst2):
#lst1 - lst2
    for i in range(len(lst1)):
        l1 = lst1[i]
        l2 = lst2[i]
        l1 -= l2
        lst1[i] = l1
            
    return lst1

if flg:
    for i in range(n):
    flg = True
    for j in range(1,m+1):
        if gokei[j-1] - algo[i][j] < x:
            flg = False
            pass
    if flg:
        gokei = hikizan(gokei,algo[i][1:])
        money -= algo[i][0]
        
print(money)


        

### FIXED CODE ###

#ABC167-C
import itertools
flg = True
n,m,x = map(int,input().split())
algo = []
tmp = []
for _ in range(n):
    algo.append(list(map(int,input().split())))
    
book = list(itertools.product([0,1],repeat=n))
abi = [0 for _ in range(m)]

for pattern in book:
    #値の初期化
    abi = [0 for _ in range(m)]
    money = 0
    flg = True
    
    for i in range(len(pattern)):
        for j in range(m):
            abi[j] += algo[i][j+1] * pattern[i]
        money += algo[i][0] * pattern[i]
        
    abi_min = [p for p in abi if p < x]
        
    if len(abi_min) != 0:
        flg = False
    if flg:
        tmp.append(money)

if len(tmp) > 0:
    print(min(tmp))
else:
    print(-1)
import sys
sys.stdin.readline()
xs = [int(x) for x in sys.stdin.readline()]
for x in reversed(xs):
  print x,

### FIXED CODE ###

import sys
sys.stdin.readline()
xs = [int(x) for x in sys.stdin.readline().split()]
for x in reversed(xs):
  print x,
a,b,c=map(int,input().split())
print(max(0,c-a+b)

### FIXED CODE ###

a,b,c=map(int,input().split())
print(max(0,c-a+b))
a,b=map(str, input().split())
t=a+b
g=1
while g*g<t:
  g+=1
if g*g==t:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b=map(str, input().split())
t=int(a+b)
g=1
while g*g<t:
    g+=1
if g*g==t:
  print('Yes')
else:
  print('No')
S=input()
if S[3]=S[4] or S[1]=S[2] or S[2]=S[3]:
  print("Bad")
  else print("Good")


### FIXED CODE ###

S = input()

if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
   print("Bad")
else:
    print("Good")
s = input()
t = input()

count = 0

for i in range(3)
	if s[i] == t[i]
	count += 1  
  	print(count)

### FIXED CODE ###

s = input()
t = input()
 
count = 0
 
for i in range(3):
		if s[i] == t[i]:
			count += 1  
    
print(count)
n = int(input())
k = len(str(n))
a = 9 * (k - 1)
b = 0
for i in range(k):
  b += int(str(n)[i])
c = 0
if k > 2:
  m = str(int(n))[:k - 2] + str(int(int(str(n)[-2]) - 1)) + '9'
  for i in range(k):
    c += int(m[i])
ans = max(a, b, c)
print(ans)

### FIXED CODE ###

n = input()
k = len(n)
a = 9 * (k - 1) + int(n[0]) - 1
b = 0
for i in range(k):
  b += int(n[i])
c = 0
m = ''
if k > 2 and n[-2] != '0':
  m = str(int(n))[:k - 2] + str(int(n[-2]) - 1) + '9'
elif k > 2 and n[-2] == '0':
  m = str(int(n) - (int(n[-1]) + 1))
for i in range(len(m)):
  c += int(m[i])
ans = max(a, b, c)
print(ans)
n, q = list(map(int, input().split(' ')))
stacks = [[] for i in range(n)]

for i in range(q):
    op = list(map(int, input().split(' ')))
    if op[0] == 0:
        stacks[op[1]].append(op[2])
    elif op[0] == 1:
        if len(stacks[op[1]]) != 0:
            print(stacks[op[1]][-1])
    elif op[0] == 2:
        stacks[op[1]].pop()


### FIXED CODE ###

n, q = list(map(int, input().split(' ')))
stacks = [[] for i in range(n)]

for i in range(q):
    op = list(map(int, input().split(' ')))
    if op[0] == 0:
        stacks[op[1]].append(op[2])
    elif op[0] == 1:
        if len(stacks[op[1]]) != 0:
            print(stacks[op[1]][-1])
    elif op[0] == 2:
        if len(stacks[op[1]]) != 0:
            stacks[op[1]].pop()
K = int(input()) 
S = input()

if len(S) > K:
    # print(S[:K])
    a = S[:K]  + '...'
    # S = S[:K].append('...')

print(a)

### FIXED CODE ###

K = int(input()) 
S = input()

if len(S) > K:
    S = S[:K]  + '...'

print(S)
import sys
import heapq
input = sys.stdin.readline

priority_que = []
N, K = map(int, input().split())
A = sorted(map(int, input().split()))
F = sorted(map(int, input().split()))[::-1]
#print(A)
#print(F)
score = [float('inf')] * K
for i, a in enumerate(A):
    f = F[i]
    for j in range(a+1):
        #print(f*j)
        if len(priority_que) > K:
            heapq.heappushpop(priority_que, f*j)
        else:
            heapq.heappush(priority_que, f*j)
#print(priority_que)
print(heapq.heappop(priority_que))


### FIXED CODE ###

import sys
import heapq


def can_eat_with_score(key):
    now_K = K
    for i, now_score in enumerate(score):
        if key < now_score:
            now_K -= (now_score-key+F[i]-1) // F[i]
            if now_K < 0:
                return False
    return True


input = sys.stdin.readline

priority_que = []
N, K = map(int, input().split())
A = sorted(map(int, input().strip().split()))
F = sorted(map(int, input().strip().split()))[::-1]
score = [A[i]*F[i] for i in range(N)]
if sum(A) <= K:
    print("0")
    exit()


left = -1
right = max(score)
while right - left > 1:
    mid = (left+right) // 2
    can_eat = can_eat_with_score(mid)
    # print(mid, can_eat)
    if can_eat:
        right = mid
    else:
        left = mid
print(left+1)
N,M=map(int,input().split())
# N:売店数
# M:買う数
AB=[]
for i in range(N):
  ab=list(map(int,input().split()))
  AB.append(ab)
#AB[0]:A円，AB[1]:最大B本まで買える

list.sort(AB,key=lambda x:x[0])
#print(AB)

m=0 #買う数
cost=0 #かかる値段
for i in range(N):
 
 if M-m==AB[i][1]:
     m+=AB[i][1]
     cost+=AB[i][0]*AB[i][1]
     break

 elif M-m<AB[i][1] :
      for j in range(AB[i][1]+1):
         cost=cost+AB[i][0]*j
         m=m+j
         if m==M:
             break
        else:
             cost=cost-AB[i][0]*j
 else:
      cost+=AB[i][0]*AB[i][1]
      m+=AB[i][1]
    
print(cost)

### FIXED CODE ###

N,M=map(int,input().split())
# N:売店数
# M:買う数
AB=[]
for i in range(N):
  ab=list(map(int,input().split()))
  AB.append(ab)
#AB[0]:A円，AB[1]:最大B本まで買える

list.sort(AB,key=lambda x:x[0])
#print(AB)

m=0 #買う数
cost=0 #かかる値段
for i in range(N):
 
 if M-m==AB[i][1]:
     m+=AB[i][1]
     cost+=AB[i][0]*AB[i][1]
     break
 elif M-m<AB[i][1] :
      for j in range(AB[i][1]+1):
         cost=cost+AB[i][0]*j
         m=m+j
         if m==M:
             break
         elif m<M:
             cost=cost-AB[i][0]*j
             m=m-j
 else:
      cost+=AB[i][0]*AB[i][1]
      m+=AB[i][1]
    
print(cost)
import math
from functools import reduce

N, X = [int(c) for c in input().split()]
x = [int(c) for c in input().split()]

if N == 1:
    print(abs(x[0] - X))
else:
    x.append(X)
    x.sort()
    print(x)
    x = [n - x[0] for n in x]
    print(x)
    D = reduce(math.gcd, x)
    print(D)

### FIXED CODE ###

#import math
from functools import reduce

N, X = [int(c) for c in input().split()]
x = [int(c) for c in input().split()]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

if N == 1:
    print(abs(x[0] - X))
else:
    x.append(X)
    x.sort()
    x = [n - x[0] for n in x]
    D = reduce(gcd, x)
    print(D)
A,B,K = map(int, input().split())
# A = int(input())
# B = int(input())
# C = int(input())
# s= input()
if A >= K:
    print(A - K,B)
elif A + B >=K:
    print(0,A + B - K)
else:
    print(0)

### FIXED CODE ###

S,T = input().split()
print(T+S)
ans = 0
for i in range(1<<n):             # 全switch(n)のon/offパターン数
    sw = [False]*m                # 各電球の点灯リストを作成
    for j in range(m):            # 各電球について
        cnt = 0
        for k in range(1,len(s[j])):   # 各電球のswitchについて
            if i>>s[j][k]&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)

### FIXED CODE ###

n, m = map(int,input().split())
s = list(list(map(int, input().split())) for _ in range(m)) 
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):
    # 全switch(n)のon/offパターン数
    sw = [False]*m
    # 各電球の点灯リストを作成
    for j in range(m):
        # 各電球について
        cnt = 0
        for k in range(1,len(s[j])):
            if i>>s[j][k]-1&1:
                cnt += 1
        if cnt%2==p[j]:
            sw[j]=True
    if all(sw):
        ans+=1
print(ans)
A,B,C = map(int,input().split())
return -A+B+C            

### FIXED CODE ###

A,B,C = map(int,input().split())
res = -A+B+C
if res <= 0:
  res = 0
print(res)
st = input()
if(st.is_lower()):
  print('A')
else:
  print('B')

### FIXED CODE ###

st = input()
if(st.islower()):
  print('a')
else:
  print('A')
a = int(input())
b = int(input())

if a == b:
    print(1)
    exit()

# 二進数xの長さを求める時、len(bin(x)) - 2　では、xが0のとき1を返してしまい、バグる原因になる
# よって、二進数の長さを計算する関数を用意しておく
def bitlen(x):
    return 1 + bitlen(x >> 1) if x else 0

t = a ^ b
n = bitlen(t)

T = 1 << (n - 1)

a = a & (T * 2 - 1)
b = b & (T * 2 - 1)

sb = b & (T - 1)
b_max = (2 ** bitlen(sb) - 1) | T

if (T + a) > b_max:
    print((b_max - a + 1) + (2 * T - 1 - (T + a) + 1))
else:
    print(2 * T - 1 - a + 1)


### FIXED CODE ###

n, a, b = map(int, input().split())

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    if a < b:
        low = a * (n - 1) + b
        high = a + b * (n - 1)
        print(high - low + 1)
    elif a == b:
        print(1)
    else:
        print(0)
x=int(input())
y=int(input())
z=int(input())

print(x//(z+y))

### FIXED CODE ###

X, Y, Z = map(int, input().split())
print((X-Z)//(Y+Z))
N = int(input())
A = map(int,input().split())
c=[]
for i in range N:
  c[i]=0
for j in A:
  c[j-1]+=1

for C in c:
  print(C)
  

### FIXED CODE ###

N = int(input())
A = map(int,input().split())
c=[]
for i in range (N):
  c.append(0)
for j in A:
  c[j-1]+=1

for C in c:
  print(C)
n=int(input())
a=list(map(int,input().split()))
b=[]
for _ in range(n):
  if a[_]<0:
    b.append(a.pop(_)*(-1))
if 0 in a or len(b)%2==0:
  print(sum(a)+sum(b))
else:
  b.sort()
  print(sum(a)+sum(b)-(b[0]*2))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
  if a[i]<0:
    c+=1
    a[i]=a[i]*-1
if c%2==0 or 0 in a:
  print(sum(a))
else:
  a.sort()
  print(sum(a[1:])-a[0])
import math

s = int(input())

MOD = 10**9+7

maximum = int(s/3)

ans = 0
for i in range(maximum):
  ans += (math.factorial(i + s-(i*3+3))/(math.factorial(i)*math.factorial(s-(i*3+3))))%MOD

print(int(ans))

### FIXED CODE ###

import math

s = int(input())

MOD = 10**9+7

maximum = int(s/3)

ans = 0
for i in range(maximum):
  ans += (math.factorial(i + s-(i*3+3))//(math.factorial(i)*math.factorial(s-(i*3+3))))%MOD

print(int(ans)%(10**9+7))
N, A = map(int, input().split())
if N % 500 <= A:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

N = int(input())
A = int(input())
if N % 500 <= A:
    print("Yes")
else:
    print("No")
# -*- coding:utf-8 -*-
import fractions

def solve():
    N = input()
    A = list(map(int, input().split()))

    # Aの要素を使って、1以上の作成可能な最も小さい値を作る。それが答え。
    # というか最大公約数が答え。

    ans = A[0]
    for i in range(1, N):
        ans = fractions.gcd(ans, A[i])
    print(ans)

if __name__ == "__main__":
    solve()


### FIXED CODE ###

def gcd(a, b):
    """ 最大公約数。aはbより大きいこと """
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    A.sort(reverse=True)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(ans, A[i])

    print(ans)


if __name__ == "__main__":
    solve()
S = map(int, input().split("/"))
if S[1] >= 5:
  print("TBD")
else:
  print("Heisei")

### FIXED CODE ###

S = list(map(int, input().split("/")))
if S[1] >= 5:
  print("TBD")
else:
  print("Heisei")
n,q = list(map(int,input().split()))
from collections import defaultdict
import sys
sys.setrecursionlimit(100000)

dd_ab = defaultdict(list)
for i in range(n-1):
    a,b = tuple(map(int,input().split()))
    dd_ab[a].append(b)

dd_px = defaultdict(int)
for i in range(q):
    p,x = tuple(map(int,input().split()))
    dd_px[p] += x

ret = [0] * (n+1)
def add_tree(node,value):
    retn = value + dd_px[node]
    ret[node] = retn
    for n in dd_ab[node]:
        add_tree(n,retn)
add_tree(1,0)
for i in ret[1::]:
    print(i)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        edges[b-1].append(a-1)
        edges[a-1].append(b-1)

    counts = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        counts[p-1] += x

    parent_nodes = deque()
    parent_nodes.append(0)
    visited_nodes = set()
    while parent_nodes:
        parent = parent_nodes.popleft()
        if parent in visited_nodes:
            continue
        visited_nodes.add(parent)
        for child in edges[parent]:
            if child in visited_nodes:
                continue
            counts[child] += counts[parent]
            parent_nodes.append(child)

    print(' '.join(list(map(str, counts))))

if __name__ == "__main__":
    main()
# Bellman-Ford
n, m = map(int, raw_bellman-input().split())
a, b, c = [], [], []
for i in xrange(m):
    at, bt, ct = map(int, raw_input().split())
    a.append(at - 1)
    b.append(bt - 1)
    c.append(ct)
# step1 : initialize
point = [-1e9 * m - 1] * n
point[0] = 0
pointl = [None] * n
# step2 : relaxation
for i in xrange(n-1):
    for j in xrange(m):
        if point[b[j]] < point[a[j]] + c[j]:
            point[b[j]] = point[a[j]] + c[j]
            pointl[b[j]] = a[j]
        print point
# step3 : check
flag = True
for j in xrange(m):
    if point[a[j]] + c[j] > point[b[j]]:
        flag = False
        break
if flag:
    print(point[n-1])
else:
    print("inf")
    


### FIXED CODE ###

# Bellman-Ford
n, m = map(int, raw_input().split())
a, b, c = [], [], []
for i in xrange(m):
    at, bt, ct = map(int, raw_input().split())
    a.append(at - 1)
    b.append(bt - 1)
    c.append(ct)
# step1 : initialize
point = [-1e9 * m - 1] * n
point[0] = 0
# step2 : relaxation
for i in xrange(n+1):
    for j in xrange(m):
        if point[b[j]] < point[a[j]] + c[j]:
            point[b[j]] = point[a[j]] + c[j]
# step3 : check
looped = [False] * n
for i in xrange(n):
    for j in xrange(m):
        if point[b[j]] < point[a[j]] + c[j]:
            looped[b[j]] = True
        if looped[a[j]] == True:
            looped[b[j]] = True
if looped[n-1]:
    print("inf")
else:
    print(point[n-1])
# -*- coding: utf-8 -*-
import itertools

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


mod = M % N
div = M // N
if mod == 0:
    print(M//N)
    exit()

f = primes(M)

# 素数の場合などは１
if len(f) <= 1:
    print(1)
    exit()

ans_list = []
for i in range(1,len(f)):
    for com in itertools.combinations(f, i):
        tmp = 1
        for c in com:
            tmp *= c
        if tmp >= N:
            ans_list.append(M//tmp)

print(max(ans_list))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import itertools
from collections import Counter

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

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


mod = M % N
div = M // N
if mod == 0:
    print(M//N)
    exit()

f = primes(M)

# 素数の場合などは１
if len(f) == 1:
    print(1)
    exit()

cnt = Counter(f)
ans_list = []

tmp_list = []
for k,v in cnt.items():
  tmp_list.append([i for i in range(v+1)])

# print(cnt)
# print(list(itertools.product(*tmp_list)))
for p in itertools.product(*tmp_list):
    tmp = 1
    for k,i in zip(cnt.keys(),p):
        tmp = tmp * (k ** i)

    if tmp > N:
        ans_list.append(M//tmp)

if len(ans_list) == 0:
    print(1)
else:
    print(max(ans_list))
import functools

n = input()
l = input().split()

if n < 3 or 10 < n:
  return 'No'

for _l in l:
	if _l < 1 or 100 < _l:
		return 'No'

longest = functools.reduce(lambda x,y: x if x > y else y, l)
sum = functools.reduce(lambda x,y: x + y, l) - longest

if longest > sum:
	return 'Yes'
else
	return 'No'



### FIXED CODE ###

import functools

n = int(input())
l = list(map(lambda x: int(x), input().split()))
    
longest = functools.reduce(lambda x,y: x if x > y else y, l)
sum = functools.reduce(lambda x,y: x + y, l) - longest

if longest >= sum:
	print('No')
else:
	print('Yes')
n = int(input())
a = list(map(int,input().split()))
if a.count(0) == n:
    print("Yes")
else:
  if n % 3 != 0:
    print("No")
  else:
    s = set(a)
    if len(s)>3:
      print("No")
    elif len(s)==2:
      if a.count(0) == n/3:
        print("Yes")
      else:
        print("No")
    else:
      l = list(s)
      if (l[0]^l[1] == l[2] and l[1]^l[2] == l[0] and l[2]^l[0] == l[1]) and (a.count(l[0])==n/3 and a.count(l[1])==n/3):
        print("Yes")
      else:
        print("No")

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
if a.count(0) == n:
    print("Yes")
else:
  if n % 3 != 0:
    print("No")
  else:
    s = set(a)
    if len(s)>3 or len(s)==1:
      print("No")
    elif len(s)==2:
      if a.count(0) == n/3:
        print("Yes")
      else:
        print("No")
    else:
      l = list(s)
      if (l[0]^l[1] == l[2] and l[1]^l[2] == l[0] and l[2]^l[0] == l[1]) and (a.count(l[0])==n/3 and a.count(l[1])==n/3):
        print("Yes")
      else:
        print("No")
W=input()
T=''
while 1:
 a=input()
 if'END_OF_TEXT '==a:break
 T+=[s.lower() for s in a.split()]
print(T.count(W))

### FIXED CODE ###

import sys
W=input()
print(sys.stdin.read().lower().split().count(W))
a = list(list(map(int,input().split())) for _ in range(3))
n = int(input())

b = set(int(input() for i in range(n)))

def check():
    for i in range(3):
        if all(a[i][j] in b for j in range(3)):
            return True
        if all(a[j][i] in b for j in range(3)):
            return True
    return all(a[i][i] in b for i in range(3)) or all(a[2-i][i] in b for i in range(3))

print('Yes' if check() else 'No')

### FIXED CODE ###

grid = list(list(map(int,input().split())) for _ in range(3))

N = int(input())

S = set(int(input()) for _ in range(N))

def check():
    for i in range(3):
        if all(grid[i][j] in S for j in range(3)):
            return True
        if all(grid[j][i] in S for j in range(3)):
            return True
    return all(grid[i][i] in S for i in range(3)) or all(grid[2-i][i] in S for i in range(3))

print('Yes' if check() else 'No')
def main():
    n,k = map(int,input().split())
    s = input()

    res = []
    buf = '1' # start:1 kara NG->s[0]
    cnt = 0
    for i in range(n):
        if s[i] == buf:
            cnt += 1
        else:
            res.append(cnt)
            buf = s[i]
            cnt = 1
    if cnt != 0:
        res.append(cnt)

    if len(res)%2 == 0:
        res.append(0) # end:1 no kosu

    #from itertools import accumulate
    #rui = list(accumulate(res))
    rui = [0]*(len(res)+1)
    for i in range(len(rui)-1):
        rui[i+1] = rui[i] + res[i]

    for i in range(0,len(res),2): # 1 only
        left = i
        right = min(i+2*k+1, len(res))
        tmp = rui[right] - rui[left]
        ans = max(tmp,ans)
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    s = input()

    res = []
    buf = '1' # start:1 kara NG->s[0]
    cnt = 0
    for i in range(n):
        if s[i] == buf:
            cnt += 1
        else:
            res.append(cnt)
            buf = s[i]
            cnt = 1
    if cnt != 0:
        res.append(cnt)

    if len(res)%2 == 0:
        res.append(0) # end:1 no kosu

    #from itertools import accumulate
    #rui = list(accumulate(res))
    rui = [0]*(len(res)+1)
    for i in range(len(rui)-1):
        rui[i+1] = rui[i] + res[i]

    ans = 0
    for i in range(0,len(res),2): # 1 only
        left = i
        right = min(i+2*k+1, len(res))
        tmp = rui[right] - rui[left]
        ans = max(tmp,ans)
    print(ans)

if __name__ == '__main__':
    main()
inf = input().split()
N = int(inf[0])
M = int(inf[1])
ls = []
for i in range(M):
  a = int(input())
  ls += [a]
step = [0 for i in range(N)]
if 1 not in ls:
  step[0] = 1
if 2 not in ls:
  step[1] = 1 + step[0]
for j in range(2, N):
  if j not in ls:
    step[j] = step[j-1]+step[j-2]
  else:
    step[j] = 0
ans = step[N-1]%(10^9+7)
print(ans)

### FIXED CODE ###

line = input().split()
N = int(line[0])
M = int(line[1])
broken = []
count = 0
step = []
def check(value):
  if count < M:
    return broken[count]==value
  else:
    return False
for i in range(M):
  a = int(input())
  broken += [a]
if check(1):
  step+=[0]
  count += 1
else:
  step +=[1]
if check(2):
  step += [0]
  count += 1
else:
  step += [1+step[0]]
for j in range(2, N):
  if check(j+1):
    step += [0]
    count += 1
  else:
    step += [step[j-2]+step[j-1]]
ans = step[N-1]%(10**9+7)
print(ans)