Harryxun/stf_run huggingface dataset:
import math
import collections
from collections import defaultdict

N = int(input())
iwa = []
mod = 10**9+7

for i in range(N):
    a, b = map(int,input().split())
    if a == 0 and b == 0:
        continue
    elif b == 0:
        iwa.appned((1,0))
    elif a == 0:
        iwa.append((0,1))
    elif b > 0:
        c = math.gcd(a,b)
        iwa.append((a/c, b/c))#bは正
    else:
        c = math.gcd(a,b)
        iwa.append((-a/c, -b/c))#bは正
        
S = set(iwa)
I = collections.Counter(iwa)
#print(I)
jdg = defaultdict(int)

ans = 1
for i in S:
    if jdg[i] == 1:
        continue
    elif i == (1,0) or i == (0,1):
        k = I[(1,0)]
        l = I[(0,1)]
        if min(k,l) == 0:
            ans *= pow(2,max(l,k),mod)
        else:
            ans *= (pow(2,l,mod)-1) + (pow(2,k,mod)-1)+1
        jdg[(1,0)] = 1
        jdg[(0,1)] = 1
    else:
        k = I[i]
        a, b = i
        if a < 0:
            l = I[(b,-a)]
            jdg[(b, -a)] = 1
        else:
            l = I[(-b,a)]
            jdg[(-b,a)] = 1
        if min(l,k) == 0:
            ans *= pow(2,max(l,k),mod)
        else:
            ans *= (pow(2,l,mod)-1) + (pow(2,k,mod)-1)+1
        jdg[i] = 1
print(ans-1)

### FIXED CODE ###

from math import gcd
from collections import defaultdict

N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
MOD = 10**9 + 7

d = defaultdict(int)#defaultdictで数えあげ
cnt_00 = 0
cnt_0b = 0
cnt_a0 = 0
for a,b in AB:
    if a == b == 0:
        cnt_00 += 1
    elif a == 0:
        cnt_a0 += 1
    elif b == 0:
        cnt_0b += 1
    else:
        num_gcd = gcd(a,b)
        grad = 1 if a * b > 0 else -1
        a //= num_gcd
        b //= num_gcd
        d[(grad, abs(a), abs(b))] += 1

ans = 1
for k in d.keys():
    if d[k] == 0:
        continue
    
    grad, a, b = k[0], k[1], k[2]
    if (-grad, b, a) in d:
        
        # 傾き a/bのものを一つ以上選ぶ場合（-b/aは選ばない） + -b/aから一つ以上選ぶ場合（a/bは選ばない） + どちらからも選ばない場合
        ans *= (pow(2, d[(grad, a, b)], MOD)-1) + (pow(2, d[(-grad, b, a)], MOD)-1) + 1
        ans %= MOD
        d[(grad, a, b)] = 0
        d[(-grad, b, a)] = 0
    else:
        # a/bから0個以上選ぶ場合
        ans *= pow(2, d[(grad, a, b)], MOD)
        ans %= MOD
        d[(grad, a, b)] = 0

# a,bの一方のみ0の場合 + どちらからも選ばない場合
ans *= (pow(2, cnt_a0, MOD)-1) + (pow(2, cnt_0b, MOD)-1) + 1
ans %= MOD

# 0,0のみを１つだけ入れる場合
ans += cnt_00
# なにも選ばない場合を除く
ans -= 1

ans %= MOD

print(ans)
import functools

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


total_votes_checker = lambda M, total_votes: (False 
                                        if total_votes < 1 / (4 * M) 
                                        else True)

total_votes = sum(A)
A_iter = iter(A)

is_acceptable = filter(total_votes_checker(next(A_iter)), total_votes)

#item_num_checker = lambda N, A: True if len(A) == N else False

popular_checker = lambda A, M: True if A[M] == max(A) else False

total_votes_checker(M, total_votes)
popular_checker(A,M)

TF = total_votes_checker(M, total_votes) and popular_checker(A,M)

printer = lambda TF : print("Yes") if True else print("No")

printer(TF)

### FIXED CODE ###

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

total_votes = sum(A)

total_votes_checker = lambda M, i, total_votes: (False if i < (1 / (4 * M)) * total_votes else True)

A = list(filter(lambda i: total_votes_checker(M, i, total_votes), A))

print("Yes") if len(A) >= M else print("No")
N , K = map(int, input().split())
Dk = list(map(int, input().split()))

for i in range(N,10*N+1):
    if set(i)&set(Dk) == set():
        print(i)


### FIXED CODE ###

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

for i in range(N,10*N+1):
    if set(str(i))&set(Dk) == set():
        print(i)
        break
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
a_tuple = tuple(map(int, input().split()))
a_set = set(a_tuple)
count_list = []

if k >= len(a_set):
    print(0)
else:
    for i in a_set:
        count = a_tuple.count(i)
        count_list.append(count)
    count_list.sort()
    ans = sum(count_list[:len(a_set)-k])
    print(ans)


### FIXED CODE ###

print(sum(int(s) for s in input()))
N = int(input())
a = [int(i) for i in input().split()]
a = list(filter(lambda x: x%2==0, a))
if len(a) == 0:
    print(0)
else:
    a = sorted(a, reverse=True)
    ans = 0
    while len(a):
        a[0] /= 2
        for i in range(1,len(a)):
            a[i] *= 3
        a = list(filter(lambda x: x%2==0, a))
        a = sorted(a, reverse=True)
        ans += 1
    print(ans)

### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in a:
    while i % 2 == 0:
        i /= 2
        ans += 1
print(ans)
N, M = map(int,input().split())
SC = [-1]*(N+1)
ans = [0]*N
for _ in range(M):
    s,c = map(int,input().split())
    if SC[s] != -1 and SC[s] != c:
        print(-1)
        exit()
    SC[s] = c
flg = 1
for i in range(10**(N-1)-1,10**N):
    s = str(i)
    for j in range(1,N+1):
        if SC[j] == -1:
            continue
        if SC[j] != int(s[j-1]):
            flg = 0
            break
    if not flg:
        flg = 1
        continue
    if flg:
        print(i)
        exit()
print(-1)

### FIXED CODE ###

N, M = map(int,input().split())
SC = [-1]*(N+1)
ans = [0]*N
for _ in range(M):
    s,c = map(int,input().split())
    if SC[s] != -1 and SC[s] != c:
        print(-1)
        exit()
    SC[s] = c
flg = 1
if N == 1:
    st = 10**(N-1) -1
else:
    st = 10**(N-1)
for i in range(st,10**N):
    s = str(i)
    for j in range(1,N+1):
        if SC[j] == -1:
            continue
        if SC[j] != int(s[j-1]):
            flg = 0
            break
    if not flg:
        flg = 1
        continue
    if flg:
        print(i)
        exit()
print(-1)
import math

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

# CとDの最小公倍数算出
bi = C*D/math.gcd(D,C)

A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
# print(B-A-sa)

Bc = B//C
Bd = B//D

Ac = A//C
Ad = A//D

print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))

### FIXED CODE ###

import fractions

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

# CとDの最小公倍数算出
bi = C*D//fractions.gcd(D,C)

A-=1
Bbi =B//bi
Abi =A//bi
sa = Bbi -Abi
# print(B-A-sa)

Bc = B//C
Bd = B//D

Ac = A//C
Ad = A//D

print(int( B-A - ((Bc-Ac) + (Bd-Ad) - sa)  ))
from itertools import permutations

n, c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]
cmat = [list(map(int, input().split())) for _ in range(n)]

dcnt = [[0] * c for _ in range(3)]
for i in range(n):
    for j in range(n):
        mod = (i + j) % 3
        dcnt[mod][c[i][j] - 1] += 1

ans = 10 ** 9
for color in permutations(range(c), 3):
    tmp = 0
    for tgt, cnt in zip(color, dcnt):
        tmp += sum(d[i][tgt] * cnt[i] for i in range(c))
    ans = min(ans, tmp)
print(ans)


### FIXED CODE ###

from collections import defaultdict
from itertools import permutations

n, c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]
cmat = [list(map(int, input().split())) for _ in range(n)]

dcnt = [defaultdict(int) for _ in range(3)]
for i, ci in enumerate(cmat, 1):
    for j, cij in enumerate(ci, 1):
        mod = (i + j) % 3
        dcnt[mod][cij - 1] += 1

ans = 1000 * n ** 2
for color in permutations(range(c), 3):
    tmp = 0
    for i, cnt in enumerate(dcnt):
        tmp += sum(d[k][color[i]] * cnt[k] for k in cnt)
    ans = min(ans, tmp)
print(ans)
n = input()

res = (n-(n/2))/n

print(ress)

### FIXED CODE ###

import math
n = int(input())

if n == 1:
    print("{:.10f}".format(1))
    exit()

res = (n-math.floor(n/2))/n


print("{:.10f}".format(res))
import numpy as np
n,k = map(int,input().split())
ary = [list(map(int,input().split())) for _ in range(n)]
ary.sort()

ans = float("Inf")
for i in range(n-k+1):
    for j in range(k,n-i+1):
        xmin = ary[i][0]
        xmax = ary[i+j-1][0]
        ary_y = sorted(ary[i:i+j], key=lambda x: (x[1]))
        for l in range(len(ary_y)-k+1):
            ymin = ary_y[l][1]
            ymax = ary_y[l+k-1][1]
            ans = min(ans,(xmax - xmin) * (ymax - ymin))
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
ary = [list(map(int,input().split())) for _ in range(n)]
ary.sort()

ans = float("Inf")
for i in range(n-k+1):
    for j in range(k,n-i+1):
        xmin = ary[i][0]
        xmax = ary[i+j-1][0]
        ary_y = sorted(ary[i:i+j], key=lambda x: (x[1]))
        for l in range(len(ary_y)-k+1):
            ymin = ary_y[l][1]
            ymax = ary_y[l+k-1][1]
            ans = min(ans,(xmax - xmin) * (ymax - ymin))
print(ans)
a,b = list(map(int,input().strip()).split())
ans1 = a + b
ans2 = b - a
if b % a == 0:
    print(ans1)
else:
    print(ans2)

### FIXED CODE ###

a,b = list(map(int,input().strip().split()))
if b % a == 0:
    print(a + b)
else:
    print(b - a)
a, b = map(int, input().splt())
if a + b >= 10:
  print("error")
else:
  print(a + b)

### FIXED CODE ###

a, b = map(int, input().split())
if a + b >= 10:
  print("error")
else:
  print(a + b)
import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.math.BigInteger;
    import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = c - a - b;
    if (d > 0 && 4 * a * b < d * d) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

### FIXED CODE ###

def DFS(word,n):
    if len(word)==N:
        return print(word)
    else:
        for i in range(n+1):
            DFS(word+chr(97+i),n+1 if i==n else n)


N=int(input())
DFS("",0)
import numpy as np

while True:
    try:
        l = list(map(int, input().split()))
        S = l[0]
        p = np.zeros(S)
        M = l[1]
        i = 0
        N = M

        while True:
            if p[i] == M:
                print(i)
                break

            if N == 0:
                N = p[i]
                p[i] = 0
                i += 1
                i %= S

            else:
                N -= 1
                p[i] += 1
                i += 1
                i %= S

    except:
        break


### FIXED CODE ###

while True:
    l = list(map(int, input().split()))
    S = l[0]
    p = [0 for i in range(S)]
    M = l[1]
    i = 0
    N = M
    if M == 0 and S == 0:
        break

    while True:
        if p[i] == M:
            print(i)
            break

        if N == 0:
            N = p[i]
            p[i] = 0
            i += 1
            i %= S

        else:
            N -= 1
            p[i] += 1
            i += 1
            i %= S
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
def B(i):
  if i==0:
    return 1
  return A[B(i-1)-1]
C=[1]
for i in range(1,N+1):
  if C.count(B(i))==0:
    C.append(B(i))
  else:
    l=C.index(B(i))+1
    break
if K<=l-1:
  print(C[K-1])
else:
  print(C[l-2+(K+2-l)%(len(C)-l+1)])

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
C=[1]
s=set([1])
for i in range(N):
  if A[C[i]-1] in s:
    l=C.index(A[C[i]-1])+1
    break
  else:
    C.append(A[C[i]-1])
    s.add(A[C[i]-1])
if K+1<=l:
  print(C[K])
else:
  print(C[l-1+(K+1-l)%(len(C)-l+1)])
s=input()
print("AC" if s[0]=="A" and C in s[2:-1] and s[1:0].replace("C","c",1).islower() else "WA")

### FIXED CODE ###

s=input()
print("AC" if (s[0]=="A") and ("C" in s[2:-1]) and (s[1:].replace("C","",1).islower()) else "WA")
S = list(int(input()))

c = 0
for i in range(3):
  if S[i] != S[i+1]:
    c += 1
if c == 3:
  print('GOOD')
else:
  print('BAD')


### FIXED CODE ###

S = list(input())

c = 0
for i in range(3):
  if S[i] != S[i+1]:
    c += 1
if c == 3:
  print('Good')
else:
  print('Bad')
import bisect
N = int(input())
P = list(map(int, input().split()))

count = 0
last_min = P[i]
for i in range(N):
    last_min = min(last_min, P[i])
    if i == 0:
        count += 1
    elif last_min == P[i]:
        count += 1
print(count)

### FIXED CODE ###

import bisect
N = int(input())
P = list(map(int, input().split()))

count = 0
last_min = P[0]
for i in range(N):
    last_min = min(last_min, P[i])
    if i == 0:
        count += 1
    elif last_min == P[i]:
        count += 1
print(count)
import math
r=int(input())
print(2*pi*r)

### FIXED CODE ###

from math import pi
r=int(input())
print(2*pi*r)
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)-min(A)>K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


### FIXED CODE ###

import fractions as math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)>=K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

l,r=a[0]*2,a[n-1]*2

while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md


p=0
cnt=0
ans=0

for i in range(n-1,-1,-1):
    while p<n:
        if a[i]+a[p]>md: break 
        p+=1
    if p==n: break
    cnt+=n-p
    ans+=a[i]*(n-p)*2

ans+=(m-cnt)*md
print(ans)


### FIXED CODE ###

import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

l,r=a[0]*2,a[n-1]*2
md=(r+l)//2
while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0

for q in range(n-1,-1,-1):
    try:
        while p<n and a[q]+a[p]<=md:
            p+=1
    except:
        b=1
        while True:
            b+=1

    if p==n: break
    cnt+=n-p
    ans+=a[q]*(n-p)*2


ans+=(m-cnt)*md
print(ans)
N, K = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
for i in h:
    ans += (h>=K)
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
for i in h:
    ans += (i >= K)
print(ans)
import math A,B = [int(c) for o in input().spit()]
print(math.ceil(A/B))

### FIXED CODE ###

import math

H, A = [int(x) for x in input().split()]
print(math.ceil(H/A))
a,b,c = input()
print('Yes' if a == c:else: 'No')

### FIXED CODE ###

a,b,c=input()
print("Yes" if a==c else "No")
# 残っているボールを1つ選んで回収、(a, b)
# (a-p, b-q) コスト0

import itertools

score = 1
p = 0
q = 0

n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

if n == 1:
    print(1)
    exit()

arr = list(itertools.permutations(e))
for i, parent in enumerate(arr):
    if i == 0:
        for j, child in enumerate(parent):
            if j == 0:
                p = parent[j + 1][0] - child[0]
                q = parent[j + 1][1] - child[1]
                score = 1
                continue
            if not child[0] == parent[j-1][0] + p and not child[1] == parent[j - 1][1] + q:
                score += 1
    else:
        tmp_p = p
        tmp_q = q
        sc = score
        for j, child in enumerate(parent):
            if j == 0:
                p = parent[j + 1][0] - child[0]
                q = parent[j + 1][1] - child[1]
                score = 1
                continue
            if not child[0] == parent[j-1][0] + p and not child[1] == parent[j - 1][1] + q:
                score += 1
            if score > sc:
                p = tmp_p
                q = tmp_q
                score = sc
                continue

print(score)


### FIXED CODE ###

N, K = (int(i) for i in input().split())

if K == 1:
    print(0)
else:
    print(N - K)
N, K = map(int, input().split())
p = list(map(int, input().split()))

calRes = 0
calIndex = 0
expectedList = []
expectedCorList = []

for i in range(N):
    cal = list(range(1, p[i] + 1))
    expectedList.append(sum(cal) * (1 / len(cal)))

    calTemp = sum(expectedList[i:i + K])
    if calRes < calTemp:
       calRes = calTemp
       calIndex = i

for l in range(K):
    expectedCorList.append(expectedList[calIndex + l])

calCor = sum(expectedCorList)
print(calCor)

### FIXED CODE ###

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

expectedList = [(1 + s) /  2 for s in p]
cumsum = sum(expectedList[:K])
confirm_cumsum = cumsum

for i in range(K, N):
    cumsum += expectedList[i]
    cumsum -= expectedList[i - K]
    if cumsum > confirm_cumsum:
        confirm_cumsum = cumsum

print(confirm_cumsum)
K, N = map(int, input().split())
A = list(map(int, input().split()))

for i in range[N]:
    dif = A[i+1]-A[i]

dif.extend([K-A[N]])

print(K-max(dif))


### FIXED CODE ###

k,n = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = a[0] + (k - a[n-1])
for i in range(1,n):
  c = max(c,a[i] - a[i-1])
print(k-c)
k = int(input())
k_under, k_over = map(int,input(),split())
result　= 1
cnt = 0
while k * cnt > k_over:
	if k * cnt > k_under:
      print('OK')
      result = 0
    cnt += 1

if result == 1:
	print('NG')
    

### FIXED CODE ###

k = int(input())
k_under, k_over = map(int,input().split())

if (k_under // k + ((k_under % k != 0) * 1)) * k > k_over:
    print('NG')
else:
    print('OK')
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    S = input().strip()
    n = int(input().strip()) - 1
    m=0
    for i in range(len(S)):
        if S[i] != '1':
            m = i
            s = S[i]
            break
    if n < m:
        print("1")
        return
    else:
        print(s)
        return


if __name__ == '__main__':
    main()


### FIXED CODE ###

from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    S = input().strip()
    n = int(input().strip()) - 1
    m=0
    for i in range(len(S)):
        if S[i] != '1':
            m = i
            break
    if n < m:
        print("1")
        return
    else:
        print(S[m])
        return


if __name__ == '__main__':
    main()
@njit
def solve():
    n, s = int(input()), input()
    a = ["R", "G", "B"]
    cnt = [0, 0, 0]
        for i in s:
        cnt[a.index(i)] += 1
    c = cnt[0] * cnt[1] * cnt[2]
    for i in range(1, n-1):
        for j in range(i+1, n):
            k = 2 * j - i
            if j-1 < k-1 < n:
                if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                    c -= 1
    return c
print(solve())

### FIXED CODE ###

n, s = int(input()), input()
a = ["R", "G", "B"]
cnt = [0, 0, 0]
for i in s:
    cnt[a.index(i)] += 1
c = cnt[0] * cnt[1] * cnt[2]
for i in range(1, n-1):
    for j in range(i+1, n):
        k = 2 * j - i
        if j-1 < k-1 < n:
            if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                c -= 1

print(c)
n,k = map(int, input().split())

count=[0]*(n+1)

for i in range(n):
  d=int(input())
  a=list(map(int, input().split()))
  ans=0
  for i in range(len(a)):
         count[i]+=1
print(count.count(0))

### FIXED CODE ###

n,k = map(int, input().split())

count=[0]*(n)

for i in range(k):
  d=int(input())
  a=list(map(int, input().split()))
  for x in a:
    count[x-1]+=1
print(count.count(0))
r = float(input())
print '%.5f %.5f' % (2*math.pi*r, math.pi*r)

### FIXED CODE ###

import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)
a,b,c=map(int,input().split())

if b=='+':
  print(a+c)
else:
  print(a-c)
  

### FIXED CODE ###

a,b,c=input().split(' ')

if b=='+':
  print(int(a)+int(c))
else:
  print(int(a)-int(c))
K = input()
S = input()
count = 0
 
for x in range(int(K)+1):
  for y in range(int(K)+1):
    z = int(S) - x - y
    if 0 <= z and z <= int(K):
    	count += 1

print(count)

### FIXED CODE ###

K, S = map(int, input().split())
count = 0
 
for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if 0 <= z and z <= K:
    	count += 1
print(count)