Harryxun/stf_run huggingface dataset:
n = int(input())
x = input()

x_cnt = x.count('1')
yp = 0
ym = 0
for i in range(n):
    yp *= 2
    yp += int(x[i])
    yp %= x_cnt + 1

    ym *= 2
    ym += int(x[i])
    ym %= x_cnt - 1


def count(z):
    cnt = 0
    while z:
        z = z % bin(z).count('1')
        cnt += 1
    return cnt


# print(x, x_cnt, yp, ym)

ans = [0] * n
bp = bm = 1
for i in reversed(range(n)):
    if x[i] == '0':
        z = (yp + bp) % (x_cnt + 1)
    else:
        z = (ym - bm + x_cnt - 1) % (x_cnt - 1)
    ans[i] = 1 + count(z)
    # print(i, z, ans[i])
    bp *= 2
    bp %= x_cnt + 1
    bm *= 2
    bm %= x_cnt - 1

print(*ans, sep='\n')


### FIXED CODE ###

n = int(input())
x = input()

x_cnt = x.count('1')
yp = 0
ym = 0
for i in range(n):
    yp *= 2
    yp += int(x[i])
    yp %= x_cnt + 1

    if x_cnt != 1:
        ym *= 2
        ym += int(x[i])
        ym %= x_cnt - 1


def count(z):
    cnt = 0
    while z:
        z = z % bin(z).count('1')
        cnt += 1
    return cnt


# print(x, x_cnt, yp, ym)

ans = [0] * n
bp = bm = 1
for i in reversed(range(n)):
    if x[i] == '0':
        z = (yp + bp) % (x_cnt + 1)
        ans[i] = 1 + count(z)
    else:
        if x_cnt == 1:
            ans[i] = 0
        else:
            z = (ym - bm + x_cnt - 1) % (x_cnt - 1)
            ans[i] = 1 + count(z)
    # print(i, z, ans[i])
    bp *= 2
    bp %= x_cnt + 1
    if x_cnt != 1:
        bm *= 2
        bm %= x_cnt - 1

print(*ans, sep='\n')
a, b = map(int, input().split())

if a == b:
    print("H")
else:
    print("D")

### FIXED CODE ###

a, b = input().split()

if a == b:
    print("H")
else:
    print("D")
N=int(input())
if N%1000=0:
  print(0)
else:
  print(1000-(N%1000))

### FIXED CODE ###

N=int(input())
if N%1000==0:
  print(0)
else:
  print(1000-(N%1000))
a, b = list(map(int, input().split()))

min = b - (a - 1)
max = b + (a - 1)

output = ''
for i in range(min, (max+1)):
  output += (i + ' ')

output.rstrip()

print(output)

### FIXED CODE ###

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

min = b - (a - 1)
max = b + (a - 1)

output = ''
for i in range(min, (max+1)):
  hoge = str(i) + ' '
  output += hoge

output.rstrip()

print(output)
n = int(input())
H = list(map(int, input().split()))

H[0] -= 1
for i in range(1, n):
    if H[i] < H[i-1]:
        H[i] -= 1
print('Yes' if reduce(lambda x, y: x <= y, H) else 'No')

### FIXED CODE ###

n = int(input())
H = list(map(int, input().split()))

H[0] -= 1
for i in range(1, n):
    if H[i-1] < H[i]:
        H[i] -= 1

if all(H[i-1] <= H[i] for i in range(1, n)):
    print('Yes')
else:
    print('No')
N=int(input())
b=1
for a in range(1,N+1):
    b*=a
numbers=[2]
for c in range(3,N+1):
    count=0
    for d in numbers:
        if not c%d==0:
            count+=1
        else:
            pass
    if count==len(numbers):
        numbers.append(c)
    else:
        pass
answers=[]
while b>1:
    for e in numbers:
        kazu=0
        while b%e==0:
            b=b/e
            kazu+=1
        answers.append(kazu)
kotae=1
for f in answers:
    kotae*=(f+1)
print(kotae)


### FIXED CODE ###

N=int(input())
b=1
for a in range(1,N+1):
    b*=a
numbers=[2]
for c in range(3,N+1):
    count=0
    for d in numbers:
        if not c%d==0:
            count+=1
        else:
            pass
    if count==len(numbers):
        numbers.append(c)
    else:
        pass
answers=[]
while b>1:
    for e in numbers:
        kazu=0
        while b%e==0:
            b=b//e
            kazu+=1
        answers.append(kazu)
kotae=1
for f in answers:
    kotae*=(f+1)
print(kotae%(10**9+7))
N = int(input())
H = list(map(int, input().split()))

ans = 0
for i in range(len(H)):
  chkflg = True
  if i >= 1:
    for j in range(i): 
      if H[j] > H[i]:
        chkflg = False
        break

  if chkflg: ans += 1

print(ans)   



### FIXED CODE ###

A, B = map(int, input().split())
ans = 0
for i in range(2):

  if A > 3 and A >= B:
    ans += A
    A -= 1
    continue

  if B > 3 and B > A:
    ans += B
    B -= 1
    continue
  
  if A == 3 and B == 3:
    ans += A

print(ans)
h, w = map(int, input().split())
a = [input() for _ in range(h)]
mod = 10**9+7

dp = [[0 for _ in range(h+1)] for _ in range(w+1)]
dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if i+1 < h and a[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= mod
        if j+1 < w and a[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= mod

print(dp[h-1][w-1])

### FIXED CODE ###

h, w = map(int, input().split())
a = [input() for _ in range(h)]
mod = 10**9+7

dp = [[0 for _ in range(w+1)] for _ in range(h+1)]
dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if i+1 < h and a[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= mod
        if j+1 < w and a[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= mod

print(dp[h-1][w-1])
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if(abs(c-a)<d*2):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

repo = list(map(int, input().split()))

if(abs(repo[2]-repo[0])<repo[3]*2):
    print('Yes')
else:
    print('No')
K = int(input())
S = input()
x = len(S)
 
if x <= K:
  print(S)
else:
  print(S[K:]　+ '...')

### FIXED CODE ###

K = int(input())
S = input()
x = len(S)
 
if x <= K:
    print(S)
else:
    print(S[:K] + '...')
S=input()
if S[0]==S[1] 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")
input = raw_input

def init():
    table = [True] * 2000001
    table[0] = False
    table[1] = False
    n = len(table)
    for i in range(2, n):
        for j in range(i + i, n, i):
            table[j] = False
    return table
    
def solve(price, ps, is_prime):
    dp = []
    for i in range(len(ps)):
        dp.append([False] * (price + 1))

    dp[0][ps[0]] = True
    dp[0][0]     = True

    for i in range(1, len(ps)):
        for p in range(price + 1):
            if p >= ps[i]:
                dp[i][p] = dp[i - 1][p] or dp[i][p - ps[i]]
            else:
                dp[i][p] = dp[i - 1][p]

    p = -1
    for i in range(0, price + 1):
        if is_prime[i] and dp[len(ps) - 1][i]:
            p = i
    if p == -1:
        print("NA")
    else:
        print(p)
    
def main():
    table = init()
    while True:
        n, price = map(int,input().split())
        if n == 0 and price == 0:
            return
        ps = []
        for i in range(n):
            ps.append(int(input()))
        solve(price, ps, table)

main()

### FIXED CODE ###

from datetime import datetime
import math

def measure(f):
    measure_start = datetime.now()
    v = f()
    print(datetime.now() - measure_start)
    return v

input = raw_input
range = xrange
    
def init():
    table = [True] * 1000001
    table[0] = False
    table[1] = False
    n = len(table)

    def prime(p):
        for i in range(p + p, n, p):
            table[i] = False
    prime(2)
    prime(3)
    prime(5)
    prime(7)
    prime(11)
    prime(13)

    for i in range(2, int(math.sqrt(n) + 1)):
        if (i % 2 != 0 and i % 3 != 0 and i % 5 != 0 and
            i % 7 != 0 and i % 11 != 0 and i % 13 != 0):
            for j in range(i * i, n, i):
                table[j] = False
#    for i in range(len(table)):
#        if table[i]:
#            print(i)
    return table
    
def solve(price, ps, is_prime):
    dp = [0] * ((price >> 5) + 1)

    for i in range(0, price + 1,ps[0]):
        dp[i >> 5] |= 1 << (i & 31)
    dp[0] = 1
    
    for i in range(1, len(ps)):
        cur_p = ps[i]
        r = cur_p & 31
        rest = 0
        if cur_p >= 32:
            for p in range(cur_p, price + 1, 32):
                i1 = (p - cur_p) >> 5
                i2 = p >> 5
                v = dp[i1]
                dp[i2] |= (v << r) | rest
                rest = (v >> (32 - r)) & ((1 << r) - 1)
        else:
            for p in range(cur_p, price + 1):
                dp[p >> 5] |= (dp[(p - cur_p) >> 5] >> ((p - cur_p) & 31) & 1) << (p & 31)
            
    p = -1
    for i in range(0, price + 1):
        if is_prime[i] and (dp[i >> 5] >> (i & 31)) & 1 == 1:
            p = i
    if p == -1:
        print("NA")
    else:
        print(p)
    
def main():
    table = init()
    while True:
        n, price = map(int,input().split())
        if n == 0 and price == 0:
            return
        ps = []
        for i in range(n):
            ps.append(int(input()))
        solve(price, ps, table)

main()
n,k,*p=map(int,open(0).read().split())
p+=0,
for i in range(n):p[i]-=~p[i-1]
print(max(p[i+k]-p[i-1]for i in range(n-k))/2)

### FIXED CODE ###

n,k,*p=map(int,open(0).read().split())
p+=0,
for i in range(n):p[i]-=~p[i-1]
print(max(p[i+k]-p[i]for i in range(-1,n-k))/2)
if [1 for c in input() if c == '9']:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

if [1 for c in input() if c == '9']:
    print('Yes')
else:
    print('No')
N = int(input())

res=0
for i in range(1, N+1):
    if(les(N)//2==1):
        rea+=1

print(res)

### FIXED CODE ###

N = int(input())

res=0
for i in range(1, N+1):
    if(len(str(i)) % 2==1):
        res+=1

print(res)
times = [int(input()) for _ in range(5)]
fraction = max([10 - t % 10 for t in times if t % 10 != 0])
if fraction == 10:
    fraction = 0
print(sum([(t - t % 10) + ((t % 10 + 9) // 10) * 10 for t in times]) - fraction)



### FIXED CODE ###

times = [int(input()) for _ in range(5)]
fractions = [10 - t % 10 for t in times if t % 10 != 0]
if fractions:
    fraction = max(fractions)
else:
    fraction = 0
print(sum([(t - t % 10) + ((t % 10 + 9) // 10) * 10 for t in times]) - fraction)
n, m = map(int, input().split())
rules = []

for x in range(m):
  rules.append(list(map(int, input().split())

def get_ans():
  if m == 0:
      return(10**(n-1)*int(bool(1<n)))

  for i in range(10**(n-1)*int(bool(1<n)), 10**n):
      for j, rule in enumerate(rules):

          if int(str(i)[rule[0]-1]) == rule[1]:
              if j == len(rules)-1:
                  return(i)
              else:
                  continue
          else:
              break
      return(-1)


print(get_ans())                    


### FIXED CODE ###

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

def get_ans():
    if m == 0:
        return(10**(n-1)*int(bool(1<n)))
        
    for i in range(10**(n-1)*int(bool(1<n)), 10**n):
        for j, rule in enumerate(rules):
            
            if int(str(i)[rule[0]-1]) == rule[1]:
                if j == len(rules)-1:
                    return(i)
                else:
                    continue
            else:
                break
                
    return(-1)


print(get_ans())
a,b=int(input().split())↲
c=a*3
d=c+d/2

print(d)↲

### FIXED CODE ###

a, p = map(int, input().split())
#print (int((a*3 + p) / 2))
#a,p=map(int,input().split())↲
print(int((a*3+p)/2))
a = list(map(int,input().split()))
b = []

for i in range(min(a[1]-a[0],2020)):
  for j in range(i):
    c = ((i+a[0])%2019)*((j+a[0])%2019)
    b.append(c)
else:
  print(min(b))
    

### FIXED CODE ###

a = list(map(int,input().split()))
b = []

if a[1]-a[0]>=2019:
  print(0)
else:
  for i in range(a[0],a[1]+1):
    for j in range(a[0],i):
      c = (i*j)%2019
      b.append(c)
  else:
    print(min(b))
x,t = map(int,input.().split())
print(x/t)

### FIXED CODE ###

x,t = map(int,input().split())
print(x/t)
S=input()
T=input()
s=len(S)
t=len(T)
max_count=0

for i in range(s-t+1):
  count=0
  for j in range(t):
    if T[i]==S[j+i]:
      count += 1
  max_count=max(max_count,count)
    
print(t-max_count)

### FIXED CODE ###

S=input()
T=input()
s=len(S)
t=len(T)
max_count=0
count=0
for i in range(s-t+1):
  for j in range(t):
    if T[j]==S[i+j]:
      count += 1
  max_count=max(max_count,count)
  count=0  
print(t-max_count)
N, K = map( int, input().split())
A = list( map( int, input().split()))
RA = A.sort( reverse = True)
s = 0
ans = 0
for a in RA:
    if s+a < K:
        s += A
        ans += 1
    else:
        ans = 0
print(ans)

### FIXED CODE ###

N, K = map( int, input().split())
A = list( map( int, input().split()))
RA = sorted(A)
RA = RA[::-1]
s = 0
ans = 0
for i in range(N):
    a = RA[i]
    if s+a < K:
        s += a
        ans += 1
    else:
        ans = 0
print(ans)
S = input
if S[0] == S[1] and S[1] == S[2]:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No')
else:
  print('Yes')
N = int(input())

if N % 2 == 0:
    print(N//2)
else:
    print(N//2+1

### FIXED CODE ###

N = int(input())

if N % 2 == 0:
    print(N//2)
else:
    print(N//2+1)
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))

### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
elif len(li_a) == 0:
  print(n-1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

if K % 2 == 1:
    A, B = B, A
print(int(A), int(B))


### FIXED CODE ###

S = input()

if len(S) == 2:
    print(S)
else:
    print(S[::-1])
costs = [2,5,5,4,5,6,3,7,6]

N, M = map(int, input().split())
A = list(map(int, input().split()))
neginf = -1 * 1e10
D = [neginf]*(N+1)

def dp(n_match):
    D[0] = 0
    for n in range(1,n_match+1):
        arr = [D[n-costs[a-1]] if n-costs[a-1]>=0 else neginf for a in A]
        D[n] = max(arr)+1

def main():
    dp(N)
    n = N
    ans = ''
    while n>0:
        for a in A:
            arr = [a for a in A if D[n-costs[a-1]]==D[n]-1]
        a = max(arr)
        ans += str(a)
        n -= costs[a-1]
    print(ans)

main()

### FIXED CODE ###

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

def main():
    a = (N//K)**3
    if K%2!=0:
        print(a)
        return
    else:
        b = ( (N+(K//2)) // K ) **3
        print(a+b)
        return

main()
def nCr(n,r):
  ret = 1
  for i in range(r):
    ret *= n-i
    ret /= i+1
  return ret

def top(N,K):
  if K == 0:
    return 1
  L = len(N)
  ans = 0
  if L < K:
    return 0
  else:
    ans += nCr(L-1,K) * 9 ** K

    u = int(N[0])
    if int(N) % u * 10 ** (L-1) != 0:
      ans += (u - 1) * nCr(L-1,K - 1) * 9 ** (K - 1)
      return ans + top(str(N[1:]),K - 1)
    else:
      return ans

N = str(input())
K = int(input())

print(int(top(N,K)))

### FIXED CODE ###

def nCr(n,r):
  ret = 1
  for i in range(r):
    ret *= n-i
    ret /= i+1
  return ret

def top(N,K):
  if K == 0:
    return 1
  L = len(N)
  ans = 0
  if L < K:
    return 0
  else:
    ans += nCr(L-1,K) * 9 ** K

    u = int(N[0])
    z = N.count('0')
    o = N.count('1')
    f = 0
    if z + o == L:
      f = 1
    if f == 0:
      ans += (u - 1) * nCr(L-1,K - 1) * 9 ** (K - 1)
      if L == 1:
        return ans + 1
      else:
        return ans + top(str(int(N[1:])),K - 1)
    else:
      if len(str(int(N[1:]))) != 1:
        return ans + top(str(int(N[1:])),K - 1)
      else:
        if o >= K:
          return ans + 1
        else:
          return ans

N = str(input())
K = int(input())

print(int(top(N,K)))
n=input()
a=0
b=753
ans=100000000
for i in renge(len(n)-2):
	a=int(n[i])*100+int(n[i+1])*10+int(n[i+2])
	ans=min(abs(a-b),ans)
print(ans)

### FIXED CODE ###

n=input()
a=0
b=753
ans=100000000
for i in range(len(n)-2):
	a=int(n[i])*100+int(n[i+1])*10+int(n[i+2])
	ans=min(abs(a-b),ans)
print(ans)
from collections import Counter
 
a = int(input())
b = [input() for _ in range(a)]
for v in ["AC", "WA", "TLE", "RE"]:
  print(f"{v} x {s.count(v)}")

### FIXED CODE ###

from collections import Counter
 
a = int(input())
b = [input() for _ in range(a)]
for v in ["AC", "WA", "TLE", "RE"]:
  print(f"{v} x {b.count(v)}")
K = int(input())
S = input()

if(len(S)<=K):
    print(S)
else:
    print(S[0:K] + "...")


### FIXED CODE ###

N = int(input())%10
yomi = {0:"pon",1:"pon",2:"hon",3:"bon",4:"hon",5:"hon",6:"pon",7:"hon",8:"pon",9:"hon"}
print(yomi[N])
N,K=map(int,input().split())
li=[map(int,input().split())]
li_sort=sorted(li,reverse=True)
print(sum(li_sort[::K]))

### FIXED CODE ###

N,K=map(int,input().split())
li=list(map(int,input().split()))
li_sort=sorted(li,reverse=True)
print(sum(li_sort[:K]))
import numpy as np
import pandas as pd

X, Y, Z = map(int, input().split())
print(Z, X, Y)

### FIXED CODE ###

X, Y, Z = map(int, input().split())
print(Z, X, Y)
print("X" * len(input())

### FIXED CODE ###

ins = input()
lens = len(ins)
print("x" * lens)
import math
N = int( input())
T = [ int( input()) for _ in range(N)]
def lcm(a,b):
    return (a*b)/math.gcd(a,b)
ans = T[0]
for i in range(1,N):
    ans = int(lcm(ans,T[i]))
print(ans)

### FIXED CODE ###

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

def lcm(a,b):
    return (a*b)//gcd(a, b)

N = int( input())
T = [ int( input()) for _ in range(N)]
ans = T[0]
for i in range(1,N):
    ans = lcm(ans,T[i])
print(ans)
a,b = input().split()

if a == "H"
    if b == "H":
        print("H")
    else:
        print("D")
else:
    if b == "H":
        print("D")
    else:
        print("H")

### FIXED CODE ###

a,b = input().split()

if a == "H":
    if b == "H":
        print("H")
    else:
        print("D")
else:
    if b == "H":
        print("D")
    else:
        print("H")
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    sorted_a = sorted(a)
    a_max = max(a)
    a_second = sorted_a[-2]

    for ai in a:
        if ai == a_max:
            print(a_second)
        else:
            print(a_max)


if __name__ == '__main__':
    main()


### FIXED CODE ###

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


def main():
    n = int(input())
    # 1-indexに
    a = [0] + list(map(int, input().split()))
    c = [0 for _ in range(n + 1)]

    # See
    # https://www.youtube.com/watch?v=-o4r74eJzV4
    # 全体の計算量は，O(N^2)のようにみえて，O(NlogN)
    # 箱iの番号が大きいものから見る
    for i in range(n, 0, -1):
        # ボールの個数の和を0で初期化
        ball_count = 0

        # iの倍数の箱を順番に見る
        # ループの範囲を[2 * i, n]として，i個飛ばしで
        for j in range(2 * i, n + 1, i):
            # mod2は，xor（排他的論理和）を使うと言い換えるとスマートに記述できる．
            # ただし，演算の順序に注意が必要
            ball_count ^= c[j]

        # i個ずつみた後の合計(mod2)とa[i]を比べる
        c[i] = a[i] ^ ball_count

    # 出力
    # ボールが入っている箱の個数とその番号
    ans = [index for index, ci in enumerate(c) if ci == 1]
    print(len(ans))
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()
n,q = map(int,input().split())
S = input()
N = [0]*(10**5+1)
for i in range(1,n+1):
    if S[i-1]=='A'and S[i]=='C':
        N[i] = 1
for i in range(q):
    l,r = map(int,input().split())
    print(sum(N[:r])-sum(N[:l]))

### FIXED CODE ###

n,q = map(int,input().split())
S = input()
N = [0]*(10**5+1)
for i in range(1,n):
    if S[i-1]=='A'and S[i]=='C':
        N[i] = 1
SUM = [0]*(10**5+1)
for i in range(1,n):
    SUM[i] += SUM[i-1]+N[i]
for i in range(q):
    l,r = map(int,input().split())
    print(SUM[r-1]-SUM[l-1])
A=input()
B=input()
C=input()
D=input()
a=int(A)
b=int(B)
c=int(C)
d=int(D)
if a<c:
    max=c
else:
    max=a
if b>d:
    min=d
else:
    min=b
if (min-max)>0:
    print(min-max)
    print('\n')
else:
    print('0\n')
quit()


### FIXED CODE ###



a,b,c,d=[int(i) for i in input().strip().split(' ')]

'''
入力は他の人のを見た
'''

max=0
min=0

if a < c :
    max=c
else :
    max=a
    
if b > d :
    min=d
else :
    min=b
if ( min - max ) > 0 :
    print( min - max )
else :
    print(0)
N, A, B = map(int, input().split())
if N == "1":
    print("Hello World")
else:
    print(A+B)

### FIXED CODE ###

N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)
a, b, k = map(int, input().split())
x = list(range(a, b+1))

print('\n'.join(map(str, x[:k] + x[-k:])))

### FIXED CODE ###

a, b, k = map(int, input().split())
x = range(a, b+1)

for i in sorted(set(x[:k]) | set(x[-k:])):
    print(i)
import re
w = input().lower()
t = ''
while True:
    s = input().lower()
    if s == 'END_OF_TEXT':
        break
    t += s

print(len(re.findall(w, t))


### FIXED CODE ###

w = input()
t = []
while True:
    s = [1 if i.lower() == w else 'fin' if i == 'END_OF_TEXT' else 0 for i in input().split()]
    t += s
    if 'fin' in s:
        break
print(t.count(1))
A, B = map(int, input().split())

if A - B > 1:
  x = 2A - 1
elif B - A > 1:
  x = 2B - 1
else:
  x = A + B

print(x)

### FIXED CODE ###

A, B = map(int, input().split())

if A - B > 1:
  x = 2 * A - 1
elif B - A > 1:
  x = 2 * B - 1
else:
  x = A + B

print(x)
import math

x1, y1, x2, y2 = map(int, input().split())

print("{a:5f}".format(a=math.sqrt(math.pow(x2 - x1, 2) + math.pow(y2 - y1, 2))))



### FIXED CODE ###

import math

x1, y1, x2, y2 = map(float, input().split())

print(math.sqrt(math.pow(x2 - x1, 2) + math.pow(y2 - y1, 2)))
#coding: utf-8

H1 = int(input("H₁="))
M1 = int(input("M₁="))
H2 = int(input("K₂="))
M2 = int(input("M₂="))
K = int(input("K="))

T = (60 * H1 + M1) - (60 * H2 + M2) - K

print(int(T))

### FIXED CODE ###

#coding: utf-8
string = str(input())
X = 0
li = []
for a in range(len(string)):
    if string[a] == " ":
        li.append(string[X:a])
        X = a+1
li.append(string[X:])
for aa in range(len(li)):
    li[aa] = int(li[aa])
h1 = li[0]
m1 = li[1]
h2 = li[2]
m2 = li[3]
k = li[4]
Time = (h2 * 60 + m2) - (h1 * 60 + m1) - k
print(int(Time))
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
INF = 100100100
n, m, l = map(int, input().split())
rinsetsu = [[INF]*n for i in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    rinsetsu[a-1][b-1] = c
    rinsetsu[b-1][a-1] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            rinsetsu[i][j]=min(rinsetsu[i][j],rinsetsu[i][k]+rinsetsu[j][k])
for i in range(n):
    for j in range(n):
        rinsetsu[i][j]=1 if rinsetsu[i][j]<=l else INF
for k in range(n):
    for i in range(n):
        for j in range(n):
            rinsetsu[i][j] = min(rinsetsu[i][j], rinsetsu[i][k]+rinsetsu[j][k])
q=int(input())
for i in range(q):
    s,g=map(int,input().split())
    s-=1;g-=1
    print(rinsetsu[s][g]-1 if rinsetsu[i][j]!=INF else -1)



### FIXED CODE ###

#!/usr/bin/env python3
import sys
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall, dijkstra
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

# f = floyd_warshall(G,directed=True(有向か、defaultはTrue))
# d = dijkstra(G, indices=0,directed=True(有向か、defaultはTrue))
n,m,l=map(int,input().split())
rinsetsu=[[0]*n for i in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    rinsetsu[a-1][b-1]=c
    rinsetsu[b-1][a-1]=c

# G = csgraph_from_dense(rinsetsu, null_value=0)
f = floyd_warshall(rinsetsu,directed=True)
# print(f)
for i in range(n):
    for j in range(n):
        f[i][j]= 1 if 1<=f[i][j]<=l else 0
# print(f)
f2= floyd_warshall(f,directed=True)

q = int(input())
for i in range(q):
    s,g=map(int,input().split())
    s-=1;g-=1
    print(int(f2[s][g])-1 if f2[s][g]!=float("inf") else -1)

# print(f2)
while(True):
    a = int(input("Enter a number"))
    b = a // 1000
    c = (a - 1000 * b) // 100
    d = a % 100 // 10

    if (d == b == c):
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

a = int(input())
b = a // 1000
c = (a - 1000 * b) // 100
d = a % 100 // 10
e=a%10
if ( b == c and c==d ):
        print('Yes')
elif(c==d and d==e):
        print('Yes')
else:
        print('No')
N = int(input())
A = int(input())
C = 0
C = N % 500
if C <= A:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

N = int(input());
A = int(input());
C = 0;
C = N % 500;
if C <= A:
  print("Yes");  
else:
  print("No");