Harryxun/stf_run huggingface dataset:
book_index = {}
    while True:
        try:
            word, page = input().split(' ')
            page = int(page)
            page_list = book_index.get(word)
            if page_list:
                page_list.append(page)
            else:
                book_index[word] = [page]
        except Exception:
            break

    for k in sorted(book_index.keys()):
        print(k)
        print(' '.join(map(str, (sorted(book_index.get(k))))))

### FIXED CODE ###

book_index = {}
while True:
    try:
        word, page = input().split(' ')
        page = int(page)
        page_list = book_index.get(word)
        if page_list:
            page_list.append(page)
        else:
            book_index[word] = [page]
    except Exception:
        break

for k in sorted(book_index.keys()):
    print(k)
    print(' '.join(map(str, (sorted(book_index.get(k))))))
def dfs(r, c):
    global color, G
    S = [r]
    color[r] = c
    while (0 < len(S)):
        u = S.pop()
        for u in G[u]:
            v = color[u]
            if (v == None):
                color[u] = c
                S.append(u)
 
def assignColor():
    global color, G, n
    c = 1
    for i in range(n):
        if (color[i] == None):
            dfs(i, c)
            c += 1
 
n, m = list(map(int, input().split()))
 
G = [None for i in range(n)]
for i in range(m):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)
 
color = [False for i in range(n)]
 
assignColor()
 
q = int(input())

for i in range(q):
    s, t = list(map(int, input().split()))
    if (color[s] == color[t]):
        print("yes")
    else:
        print("no")

### FIXED CODE ###

def dfs(r, c):
    global color, G
    S = [r]
    color[r] = c
    while (0 < len(S)):
        u = S.pop()
        for u in G[u]:
            v = color[u]
            if (v == None):
                color[u] = c
                S.append(u)
 
def assignColor():
    global color, G, n
    c = 1
    for i in range(n):
        if (color[i] == None):
            dfs(i, c)
            c += 1
 
n, m = list(map(int, input().split()))
 
G = [[] for i in range(n)]
for i in range(m):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)
 
color = [None for i in range(n)]
 
assignColor()
 
q = int(input())

for i in range(q):
    s, t = list(map(int, input().split()))
    if (color[s] == color[t]):
        print("yes")
    else:
        print("no")
a = int(input())

print("ABC") if x < 1200 else print("ARC")

### FIXED CODE ###

a = int(input())

print("ABC") if a < 1200 else print("ARC")
#coding:utf-8
n=[int(i) for i in input().split()]
if(n[0]%n[1]=0):
  print(0)
else:
  print(1)

### FIXED CODE ###

#coding:utf-8
n=[int(i) for i in input().split()]
if(n[0]%n[1]==0):
  print(0)
else:
  print(1)
s = str(input())
t = s[::-1]
if(s != t):
    print("No")
    exit
c = ""
for i in range((len(s)-1)//2):
    c += s[i]
e = c[::-1]
if(e != c):
    print("No")
    exit()
r = ""
for i in range(((len(s)+3)//2)-1,len(s),1):
    r += s[i]
y = r[::-1]
if(r != y):
    print("No")
    exit()
"""
print("Yes")
print(s,t)
print(e,c)
print(r,y)

### FIXED CODE ###

s = str(input())
t = s[::-1]
if(s != t):
    print("No")
    exit()
c = ""
for i in range((len(s)-1)//2):
    c += s[i]
e = c[::-1]
if(e != c):
    print("No")
    exit()
r = ""
for i in range(((len(s)+3)//2)-1,len(s),1):
    r += s[i]
y = r[::-1]
if(r != y):
    print("No")
    exit()
print("Yes")
"""
print(s,t)
print(e,c)
print(r,y)
"""
N = int(input())
INF = 10**6
dp = [INF] * (max(9, N))
for i in range(10):
  if  0 < i < 6:
    dp[i] = i
  elif i < 9:
    dp[i] = i%6+1
for i in range(N):
  n = m = 1
  while i+9**n <= N:
    dp[i+9**n] = min(dp[i+9**n], dp[i] + 1)
    n += 1
  while i+6**m <= N:
    dp[i+6**m] = min(dp[i+6**m], dp[i] + 1)
    m += 1
print(dp[N])


### FIXED CODE ###

N = int(input())
if N >= 1000:
  print('ABD')
else:
  print('ABC')
S = list(input())
if S = "abc" or S = "acb" or S = "bac" or S = "bca" or S = "cab" or S = "cba":
    print("Yes")
else:
    print("No")

### FIXED CODE ###

print("Yes" if set(list(input())) == set(["a","b","c"]) else "No")
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

if n % 2 == 1:
    info = sorted(info)
    l = info[n // 2][0]
    info = sorted(info)[::-1]
    r = info[n // 2][1]
    print(r - l + 1)
else:
    print(re)


### FIXED CODE ###

from operator import itemgetter

n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
a = [info[i][0] for i in range(n)]
b = [info[i][1] for i in range(n)]

a = sorted(a)
b = sorted(b)
if n % 2 == 1:
    l = a[n // 2]
    r = b[n // 2]
    print(r - l + 1)
else:
    l1, l2 = a[n // 2 - 1], a[n // 2]
    r1, r2 = b[n // 2 - 1], b[n // 2]
    print((r1 + r2) - (l1 + l2) + 1)
import sys
readline = sys.stdin.buffer.readline

N, M = map(int, readline().split())
ans = [0 for _ in (N + 1)]
append_ans = ans.append
graph = [[] for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

root = 1
q = [root]
append_q = q.append
checked = [0] * (N + 1)
checked[root] = 1
order = []
append_order = order.append
parent = [-1 for _ in range(N+1)]

while q:
    x = q.pop(0)
    for y in graph[x]:
        if checked[y]:
            continue
        if parent[y] != -1:
            continue
        parent[y] = x
        append_ans(x)
        append_order(y-2)
        checked[y] = 1
        append_q(y)

if len(order) != N - 1:
    print('No')
else:
    print('Yes')
    for i in range(len(order)):
        j = order.index(i)
        print(ans[j])

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

N, M = map(int, readline().split())
m = map(int, read().split())
AB = list(zip(m, m))
graph = [[] for _ in range(N+1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
q = [root]
checked = [0] * (N + 1)
checked[root] = 1
order = []
D = [0 for _ in range(N+1)]
d = 0
while q:
    x = q.pop(0)
    d = D[x]
    for y in graph[x]:
        if checked[y]:
            continue
        D[y] = d + 1
        checked[y] = 1
        q.append(y)

ans = [0 for _ in range(N+1)]
for a, b in AB:
    d_a, d_b = D[a], D[b]
    if d_a < d_b:
        ans[b] = a
    elif d_a > d_b:
        ans[a] = b

print('Yes')
print('\n'.join(map(str, ans[2:])))
l=(str(r)+str(g)+str(b))
if 0 == (int(l)%4):
  print('YES')
else:
  print('NO')

### FIXED CODE ###

r,g,b=map(int,input().split())
l=(str(r)+str(g)+str(b))
if 0 == (int(l)%4):
  print('YES')
else:
  print('NO')
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            f = False
            if 0 <= j+1 < h and 0 <= i < w and s[i][j+1] == "#":
                f = True
            if 0 <= j-1 < h and 0 <= i < w and s[i][j-1] == "#":
                f = True
            if 0 <= j < h and 0 <= i+1 < w and s[i+1][j] == "#":
                f = True
            if 0 <= j < h and 0 <= i-1 < w and s[i-1][j] == "#":
                f = True
            if not f:
                print("No")
                exit()
print("Yes")

### FIXED CODE ###

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
if h == 1 and w == 1:
    print("Yes")
    exit()

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            f = False
            if 0 <= i+1 < h and 0 <= j < w and s[i+1][j] == "#":
                f = True
            if 0 <= i-1 < h and 0 <= j < w and s[i-1][j] == "#":
                f = True
            if 0 <= i < h and 0 <= j+1 < w and s[i][j+1] == "#":
                f = True
            if 0 <= i < h and 0 <= j-1 < w and s[i][j-1] == "#":
                f = True
            if not f:
                print("No")
                exit()
print("Yes")
import math
import itertools

def l2(z1, z2):
  return math.sqrt(pow(z1[0] - z2[0], 2) + pow(z1[1] - z2[1], 2))

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

dist = 0
z_fr = []
z_to = []
for seq in itertools.permutations(l, n):
  for z in seq:
    z_fr = z_to
    z_to = z
    if len(z_fr):
      continue
    dist += l2(z_fr, z_to)

#print(dist/math.factorial(n))
print('2.2761423749')

### FIXED CODE ###

import math
import itertools

def l2(z1, z2):
  return math.sqrt(pow(z1[0] - z2[0], 2) + pow(z1[1] - z2[1], 2))

n = int(input())
l = [list(map(int, input().split(' '))) for _ in range(n)]
seq_list = itertools.permutations(l, n)

dist = 0
for seq in seq_list:
  z_fr = []
  z_to = []
  
  for z in seq:
    z_fr = z_to
    z_to = z
    if len(z_fr)==0:
      continue
    dist += l2(z_fr, z_to)

print(dist/math.factorial(n))
from functools import lru_cache

n, m = [int(i) for i in input().split()]

@lru_cache(maxsize=10000)
def countPattern(s, cnt):
    if s > 1:
        cnt = countPattern(s-2, cnt)
        cnt = countPattern(s-1, cnt)
        return cnt
    else:
        return cnt + 1


ans = 1
a_pre = -1
for mi in range(m):
    a = int(input())
    if a == a_pre:
        break
    elif a == a_pre + 1:
        ans = 0
    ans = ans * countPattern(a-a_pre-2, 0) % 1000000007
    a_pre = a

a = n + 1
ans = ans * countPattern(a - a_pre - 2, 0) % 1000000007

print(ans)

# TLE

### FIXED CODE ###

n, m = [int(i) for i in input().split()]

b = [0 for i in range(n+1)]

for mi in range(m):
    b[int(input())] = 1
cnt = 0
s = [0 for i in range(n+1)]
s[0] = 1
if b[1] == 0:
    s[1] = 1
else:
    s[1] = 0
for ni in range(2,n+1):
    if b[ni] == 0:
        s[ni] = (s[ni-1] + s[ni-2]) % 1000000007
    else:
        s[ni] = 0
print(s[n])
n,a,b = map(int,input().split())
if a+b>n+1 or a*b<n:
  print(-1)
  exit()
ans = []
for i in range(1,a+1):
  ans.append(i*b)
x = (n-a)//(b-1)
y = (n-a)%(b-1)
for i in range(1,b):
  for j in range(1,x+1):
    ans.append(j*b-i)
  if i <= y:
    ans.append((x+1)*b-i)
ans_true = []
for i,x in enumerate(ans):
  ans_true.append((i+1,x))
ans_true.sort(key=lambda x:x[1])
print(*list(zip(*ans_true))[0])


### FIXED CODE ###

n,a,b = map(int,input().split())
if a+b>n+1 or a*b<n:
  print(-1)
  exit()
ans = []
for i in range(1,a+1):
  ans.append(i*b)
if b == 1:
  x = list(range(1,n+1))
  print(*x)
  exit()
x = (n-a)//(b-1)
y = (n-a)%(b-1)
for i in range(1,b):
  for j in range(1,x+1):
    ans.append(j*b-i)
  if i <= y:
    ans.append((x+1)*b-i)
ans_true = []
for i,x in enumerate(ans):
  ans_true.append((i+1,x))
ans_true.sort(key=lambda x:x[1])
x = list(zip(*ans_true))[0]
print(*x)
import sys
mem = [0] * 26
for s in sys.stdin:
  for c in s.upper():
    if(c < 'A' or c > 'Z'):
      continue
    mem[ord(c) - ord('A')] += 1
  for i in range(26):
    print chr(i + ord('a')) + " : %d" % mem[i

### FIXED CODE ###

import sys
mem = [0] * 26
for s in sys.stdin:
  for c in s.upper():
    if(c < 'A' or c > 'Z'):
      continue
    mem[ord(c) - ord('A')] += 1
for i in range(26):
  print chr(i + ord('a')) + " : %d" % mem[i]
a,b,c,d,e,k=int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
k = inputs.pop(5)
if inputs[-1] - inputs[0] > k:
  print('Yay!')
else:
  print(':(')

### FIXED CODE ###

a,b,c,d,e,k=int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
if e-a > k:
  print(':(')
else:
  print('Yay!')
n = int(input())
s = list(input())
count = 0
if n % 3 != 0:
  for i in range (1,n):  
    if s[i-1] == 'A' and s[i] == 'B' and s [i+1] == 'C':
      count += 1
elif n % 3 == 0:
  for i in range(1, n-1):
    if s[i-1] == 'A' and s[i] == 'B' and s [i+1] == 'C':
      count += 1
print(count)

### FIXED CODE ###

n = int(input())
s = str(input())
count = 0
if n % 3 == 1 or n % 3 == 0:
  for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
      count += 1
elif n % 3 == 2:
  for i in range(n-2):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
      count += 1
print(count)
s =input()
t =input()
n = len(s)
d = {}
used = set([])

for i in range(n):
  if s[i] not in d:
    if t[i] in used:
      print('No')
      continue
    d[s[i]] = t[i]
    used.add(t[i])
  else:
    if d[s[i]] == t[i]:
      continue
    else:
      print('No')
      break
else:
  print('Yes')


### FIXED CODE ###

l = sorted(list(map(int,input().split())))
print(l[2]*10 + l[1] + l[0])
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_num = 0
b_num = 0
while True:
    if a_num == len(a) and b_num == len(b):
        break
    elif a[b_num] <= k and b_num == len(b) and a_num < len(a):
        k -= a[a_num]
        a_num += 1
        continue
    elif b[b_num] <= k and a_num == len(a) and b_num < len(b):
        k -= b[b_num]
        b_num += 1
        continue
    elif a[a_num] <= k and a[a_num] <= b[b_num] and a_num < len(a):
        k -= a[a_num]
        a_num += 1
        continue
    elif b[b_num] <= k and b[b_num] < a[a_num] and b_num < len(b):
        k -= b[b_num]
        b_num += 1
        continue
    else:
        break
print(a_num + b_num)
        

### FIXED CODE ###

n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
for i in range(n+1):
    if A[i] > k:
        break
    while B[m] > k-A[i]:
        m -= 1
    ans = max(ans,i+m)
print(ans)
n = int(input())
x = [int(i) for i in input().split()]
d = {}

def m(x, p):
  a = (x - p)**2
  return a
#d.setdefault(j, []).append([i, j, m(i,j)])
for i in range(min(x), max(x)):
  b = 0
  for j in x:
    b += m(j,i)
  d[i]=[b]
print(min(d.values())[0]

### FIXED CODE ###

n = int(input())
x = [int(i) for i in input().split()]
d = []
for i in range(min(x), max(x)+1):
  a = 0
  for j in x:
    a += (j - i)**2
#    print("({}-{})**2={}".format(j,i,(j - i)**2))
  d.append(a)
print(min(d))
# -*- coding: utf-8 -*-

import itertools

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

a = list(range(1,n+1,1))
count = 1

for i in itertools.permutations(a, n):
    if (i[0] == p[0]) and (i[1] == p[1]) and (i[2] == p[2]):
        res1 = count
    if (i[0] == q[0]) and (i[1] == q[1]) and (i[2] == q[2]):
        res2 = count
    count += 1

print(abs(res1-res2))

### FIXED CODE ###

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

import itertools

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

a = list(range(1,n+1,1))
count = 1

res1 = 0
res2 = 0

temp = []

for i in itertools.permutations(a):
    for j in range(n):
        temp.append(i[j])
    if temp == p and (res1 == 0):
        res1 = count
    if temp == q and (res2 == 0):
        res2 = count
    count += 1
    temp = []

print(abs(res1-res2))
N, D = map(int, input().split())
    X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0

def dist(A, B):
    sums = 0
    for i in range(len(A)):
        sums += (abs(A[i] - B[i])) ** 2
    sums = sums ** 0.5
    return sums

for i in range(N-1):
    for j in range(i+1, N):
#            if isinstance(dist(X[i], X[j]), int):
        if dist(X[i], X[j]).is_integer():
            cnt += 1
print(cnt)

### FIXED CODE ###

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
 
def dist(A, B):
    sums = 0
    for i in range(len(A)):
        sums += (abs(A[i] - B[i])) ** 2
    sums = sums ** 0.5
    return sums
 
for i in range(N-1):
    for j in range(i+1, N):
#            if isinstance(dist(X[i], X[j]), int):
        if dist(X[i], X[j]).is_integer():
            cnt += 1
print(cnt)
def gcd(x,y):
	while y != 0:
		x , y = y , x % y
	return x

def lcm(x,y):
    return int(x*y/gcd(x,y))


n = int(input())

a =[]
for i in range(n):
    a.append(int(input()))

for i in range(n-1):
    a[i+1] = lcm(a[i],a[i+1])
print(a[-1])

### FIXED CODE ###

def gcd(x,y):
	while y != 0:
		x , y = y , x % y
	return x

def lcm(x,y):
    return x*y//gcd(x,y)


n = int(input())

a =[]
for i in range(n):
    a.append(int(input()))

for i in range(n-1):
    a[i+1] = lcm(a[i],a[i+1])
print(a[-1])
S = input()
stack = []
cnt = 0

for s in S:
    if s == S[0]:
        stack.append(s)
    elif s == '0' and s != stack[-1]:
        stack.pop()
        cnt += 2
    elif s == '1' and s != stack[-1]:
        stack.pop()
        cnt += 2
    else:
        stack.sppend(s)
        
print(cnt)
         

### FIXED CODE ###

s = input()
n = len(s)

one = s.count('1')
zero = s.count('0')

print(2*min(one, zero))
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)].sort()
pm = s = 0
m_minus_1 = m - 1
for item in a:
    pm += item[1]
    if pm > m_minus_1:
        print(s + item[0] * (m - pm + item[1]))
        break
    else:
        s += item[0] * item[1]


### FIXED CODE ###

n, m = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
a.sort()
pm = s = 0
for item in a:
    if pm + item[1] >= m:
        print(s + item[0] * (m - pm))
        break
    else:
        pm += item[1]
        s += item[0] * item[1]
N = int(input())
Nlist=[]
Takalist=[]
Aokilist=[]
for n in range(N):
    Nlist.append(n)
    a,b = map(int,input().split())
    Takalist.append(a)
    Aokilist.append(b)

Taka = 0
Aoki = 0


flg = 0
for n in range(N):
    if flg == 0:
        big = max(Takalist)
        Taka += big
        num = Takalist.index(big)
        Aokilist[num]=0
        Takalist[num]=0
        flg=1

    elif flg == 1:
        big = max(Aokilist)
        Aoki += big
        num = Aokilist.index(big)
        Aokilist[num]=0
        Takalist[num]=0
        flg=0

print(Taka-Aoki)


### FIXED CODE ###

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

sum = A+B
if A+B <= N:
    min = 0
else:
    min = (A+B)-N

#max
if A >= B:
    max=B
else:
    max = A

print(max,min)
a = input()
b = input()
aa = [s for s in a]
bb = [s for s in b]
na = len(a)
nb = len(b)

dp = [[0]*(na+1) for _ in range(nb+1)]
k = 0
for i in range(na):
    if a[i] == b[0]:
        k = 1
    dp[i][0] = k
k = 0
for i in range(nb):
    if b[i] == a[0]:
        k = 1
    dp[0][i] = k

for i in range(1, na):
    for j in range(1, nb):
        if a[i] == b[j]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = []
x = na-1
y = nb-1
while x != 0 and y != 0:
    if x-1 >= 0 and dp[x][y] == dp[x-1][y]:
        x = x-1
    elif y-1 >= 0 and dp[x][y] == dp[x][y-1]:
        y = y-1
    else:
        ans.append(a[x])
        x = x-1
        y = y-1
if a[0] == b[0]:
    ans.append(a[0])

print("".join(ans[::-1]))


### FIXED CODE ###

a = input()
b = input()
na = len(a)
nb = len(b)

dp = [[0]*(nb+1) for _ in range(na+1)]

for i in range(na):
    for j in range(nb):
        if a[i] == b[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
ans = []
num = dp[na][nb]
x = na
y = nb
while num:
    if dp[x][y] == dp[x-1][y]:
        x -= 1
    elif dp[x][y] == dp[x][y-1]:
        y -= 1
    else:
        ans.append(a[x-1])
        x -= 1
        y -= 1
        num -= 1

print("".join(ans[::-1]))
import sys
import numpy as np

def main(N, S):
    dp = np.zeros((N + 1, N + 1), dtype=int)
    ans=0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i][j] = min(j - i, dp[i - 1][j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, max(dp[i]))
    return ans

if sys.argv[-1] == 'ONLINE_JUDGE' and 0:
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc.export('main', 'i8(i8,i8[:])')
    cc.compile()

from my_module import main

N = int(input())
S = [ord(_) for _ in input()]
print(main(N, S))


### FIXED CODE ###

import itertools
N = int(input())
S = input()
dp = [[0] * N for _ in range(N)]
ans = 0
for i, j in itertools.combinations(range(N), 2):
    if S[i] == S[j]:
        dp[i][j] = dp[i - 1][j - 1] + 1
    else:
        dp[i][j] = 0
    ans = max(ans, min(j - i, dp[i][j]))
print(ans)
A,B = map(int,input().split())

import math

GCD = math.gcd(A,B)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

PF = prime_factorize(GCD)

PF = list(set(PF))

res = len(PF) + 1

print(res)


### FIXED CODE ###

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

import fractions

GCD = fractions.gcd(A,B)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

PF = prime_factorize(GCD)

PF = set(PF)

res = len(PF) + 1

print(res)
N,S=input()
print(S.count("abc"))

### FIXED CODE ###

N=int(input())
S=input()
print(S.count("ABC",0,N))
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  mod=pow(10,9)+7
  ans=[1]*(n+1)
  for _ in [0]*m:
    ans[int(input())]=0
  ans[2]=ans[1]+1 if ans[2]!=0 else 0
  for i in range(3,n+1):
    if ans[i]>0:
      ans[i]=(ans[i-1]+ans[i-2])%mod
  print(ans[-1])
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  mod=pow(10,9)+7
  ans=[1]*(n+1)
  for _ in [0]*m:
    ans[int(input())]=0
  for i in range(n+1):
    ans[i]=ans[i] if ans[i]==0 or i<2 else (ans[i-1]+ans[i-2])%mod
  print(ans[-1])
if __name__ == '__main__':
    main()
from sys import stdin, stdout
n,capacity=map(int,stdin.readline().split())
weights=[0]*n
values=[0]*n
for i in range(n):
    weights[i],values[i]=map(int,stdin.readline().split())
dp=[[0]*(capacity+1) for i in range(n+1)]
for i in range(n+1):
    for j in range(weights+1):
        if(weights[i-1]<=j):
            dp[i][j]=max(values[i-1]+dp[i-1][j-weights[i-1]],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[n][capacity])

### FIXED CODE ###

# from sys import stdin, stdout
n,capacity=map(int,input().split())
weights=[0]*n
values=[0]*n
for i in range(n):
    weights[i],values[i]=map(int,input().split())
dp=[[0]*(capacity+1) for i in range(n+1)]
for i in range(1,n+1):
    for j in range(1,capacity+1):
        if(weights[i-1]<=j):
            dp[i][j]=max(values[i-1]+dp[i-1][j-weights[i-1]],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[n][capacity])
s=input()
t=input()
a=0
for i in len(s):
  if s[i]=!t[i]:
  a +=
print(a)
 

### FIXED CODE ###

s=input()
t=input()
a=0
for i in range(len(s)):
    if s[i]!=t[i]:
        a += 1
print(a)
n=input()
a=1
while a*2<=n:
 a*=2
print(a)

### FIXED CODE ###

n=int(input())
a=1
while a*2<=n:
 a*=2
print(a)
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(len(a)):
    ans*=a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
N=int(input())
ans=1
for i in range(1,N):
    if i*i<=N:
        ans=i*i
print(ans)

### FIXED CODE ###

a,b,c,d=map(int, input().split())
E=abs(b-a)
F=abs(c-b)
G=abs(c-a)
if E<=d and F<=d:
	print("Yes")
elif G<=d:
	print("Yes")
else:
	print("No")
# -*- coding: utf-8 -*-
#入力
N,K,Q=map(int,input().split())
a=[int(input()) for i in range(Q)]

for i in range(0,N,1):
    j=re.findall(i,a)
    if(K+len(j)-Q>0):print("Yes")
    else:print("No")


### FIXED CODE ###

# -*- coding: utf-8 -*-
#入力

N,K,Q=map(int,input().split())
a=[int(input()) for _ in range(Q)]
b=[0]*N
for i in a:
    b[i-1]+=1
for l in range(0,N,1):
    if(K+b[l]-Q>0):print("Yes")
    else:print("No")
if __name__ == '__main__':
    #AB = [int(i) for i in input().split()]
    S = input()
    K = int(input())
    for i in S:
        if i == K:
            print(n)
            break
        if i != '1':
	    print(n)
	    break

### FIXED CODE ###

if __name__ == '__main__':
    # AB = [int(i) for i in input().split()]
    S = str(input())
    K = int(input())
    for n, i in enumerate(S):
        if n+1 == K:
            print(i)
            break
        if i != '1':
            print(i)
            break