peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(int,input().split()))

counter = 0
place_list = []
place_set = set()
next = 1
while True:
    
    if  next in place_set:
        break
        
    else:
        place_list.append(next)
        place_set.add(next)
        next = A[next-1]
        
    counter += 1

duration_cycle = len(place_list)- place_list.index(next)
if K <len(place_list):
    print(place_list[K])
else:
    print(place_list[(K-place_list.index(next))%duration_cycle+place_list.index(next)])
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

x,y,z=list(map(int,input().split()))

print((x+z)//(y+z))
# Judge status: Wrong Answer
from fractions import gcd

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

x = 0
for i in range(n-1):
    x = gcd(x,l[i])

print(x)
# Judge status: Accepted
s = input()
a = ""
for i in range(len(s)):
  if s[i] == "B":
    a = a[:-1]
  else:
    a += s[i]
print(a)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
arai = sum(A)
sunuke = 0

ans = 10**10
for i in range(0, N-1):
    sunuke += A[i]
    arai -= A[i]
    ans = min(ans, abs(sunuke - arai))

print(ans)
# Judge status: Accepted
N,W = map(int,input().split())
goods = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(W)] for _ in range(N)]

for i,[w,v] in enumerate(goods):
  for j in range(W):
    if i == 0:
      if j >= goods[0][0]-1:
        dp[0][j] = goods[0][1]
    else:
      if w <= j:
        dp[i][j] = max(v+dp[i-1][j-w],dp[i][j-1],dp[i-1][j])
      else:
        dp[i][j] = dp[i-1][j]

print(dp[N-1][W-1])
# Judge status: Wrong Answer
def main():
    n = int(input())
    h = list(map(int, input().split()))

    res = 0
    for i in range(n-1):
        if h[i] < h[i+1]:
            res = i+1
    if res+1 == n:
        print(0)
    else:
        print(n-(res+1))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, M = map(int, input().split())
x = sorted(map(int, input().split()))
if N >= M:
    print(0)
diff = [0]*(M-1)
for i in range(M-1):
    diff[i] = x[i+1] - x[i]
diff.sort()
ans = sum(diff[:M-N])
print(ans)
# Judge status: Accepted
X, Y = map(int, input().split())
n = 1
while True:
    X *= 2
    if X <= Y:
        n += 1
    else:
        break

print(n)
# Judge status: Accepted
a,b,x = map(int,input().split())
def count(c):
  if c==0:
    return 0
  return c//x
print(count(b)-count(a-1))
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))
# Judge status: Accepted
S = input()
K = int(input())

ans = 1
for i in S:
	if i != '1':
		ans = i
		break
	if K==1:
		ans = i
		break
	K-=1
print(ans)
# Judge status: Accepted
from collections import deque
N, M = map(int, input().split())
ways = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  ways[a].append(b)
  ways[b].append(a)
searched = [0 for i in range(N)]
searched[0] = 1
ans = [0 for i in range(N)]
d = deque([])
d.append(0)
while d:
  tmp = d.popleft()
  for w in ways[tmp]:
    if searched[w] == 0:
      searched[w] = 1
      ans[w] = tmp
      d.append(w)
print("Yes")
for a in ans[1:]:
  print(a + 1)
# Judge status: Accepted
import collections
s1=input()
s2=input()
s1 = list(s1)
s2 = list(s2)

s11 = collections.Counter(s1)
s22 = collections.Counter(s2)

if len(s11) != len(s22):
    print('No')
    exit()

for i in range(len(s11)):
    if s11.most_common()[i][1] != s22.most_common()[i][1] :
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
n = int(input())
s = str(input())
t = str(input())

for i in range(n):
  s_ = s[i:]
  t_ = t[:n-i]
  if s_ == t_:
    print(n+i)
    exit()
else:
  print(2*n)
# Judge status: Accepted
X = int(input())
if X >=30 :
    print("Yes")
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
X = input()
mL = 0
for i in X:
  if i == ")":
    mL += 1
  else:
    break
mR = 0
for i in X[::-1]:
  if i == "(":
    mR += 1
  else:
    break
result = mL * "(" + X + mR * ")"
L = len([i for i in result if i != "("])
R = len(result) - L
if L > R:
  result = (L - R) * "(" + result
else:
  result += (R - L) * ")"
print(result)
# Judge status: Wrong Answer
A,B,C = map(int,input().split(" "))
Amod = A%B

if Amod==0:
    if C!=0:
        print("NO")
    else:
        print("YES")
else:
    i=0
    while(i<=B):
        i+=1
        c = (i%B * Amod)
        if (c%B==C):
            print("YES")
            break
    if(i>B):
        print("No")
# Judge status: Accepted

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

weights = []
profits = []

for i in range(n):
    x, y = map(int, input().split())
    weights.append(x)
    profits.append(y)

dp = [[0 for i in range(w+1)] for j in range(n+1)]

for i in range(1, n+1):
    for j in range(1, w+1):

        if weights[i-1] <= j:
            dp[i][j] = max(dp[i-1][j], profits[i-1] + dp[i-1][j-weights[i-1]])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[n][w])
# Judge status: Accepted
n, a, b = map( int, input().split() )
if a > b:
  exit( print( 0 ) )
if n == 1:
  exit( print( 1 if a == b else 0 ) )
else:
  x = ( n - 1 ) * a + b
  y = ( n - 1 ) * b + a
  print( y - x + 1 )
# Judge status: Wrong Answer
n, m, x = map(int, input().split())
ans = 10000001
books = []
for i in range(n):
  a = list(map(int, input().split()))
  books.append(a)
  
for i in range(2**n):
  _trigger = True
  _sum = [0 for k in range(m+1)]
  for j in range(n):
    if ((i >> j) & 1):
      for k in range(m+1):
        _sum[k] += books[j][k]
  for j in range(1, m):
    if _sum[j] < x:
      _trigger = False
      
  if (_trigger == True and ans > _sum[0]):
      ans = _sum[0]
    
if (ans == 10000001):
  print (-1)
else:
  print (ans)
# Judge status: Accepted
import math
x = int(input())
n = int(math.sqrt(x))
flg = True
while 1:
    for i in range(2,n):
        if x % i == 0:
            flg = False
            break
    if flg:
        print(x)
        break
    else:
        x += 1
        n = int(math.sqrt(x))
        flg = True
# Judge status: Wrong Answer
S = input()
T = input()
L = len(S)
K = len(T)
ans = S
flag = 0
for i in range(L-1,-1,-1):
    for j in range(K-1,-1,-1):
        a = K-1-j
        print(S[i-a],T[j])
        if i-a < 0 or (S[i-a] != "?" and S[i-a] != T[j]):
            break
    else:
        ans = ans[:i-K+1] + T + ans[i+K:]
        flag = 1
        break
if flag == 0:
    ans = "UNRESTORABLE"
print(ans.replace("?","a"))
# Judge status: Wrong Answer
n, m = map(int, input().split())
name = []
city = []
prefecture = [1] * n
for i in range(m):
    a = list(map(int, input().split())) + [i+1]
    city.append(a)
    name.append("{}{}".format("0" * (6 - len(str(a[0]))), a[0]))


for i in range(m):
    p, y, num = city[i]
    x = prefecture[p-1]
    name[num-1] += "{}{}".format("0" * (6 - len(str(x))), x)
    prefecture[p-1] += 1
for i in name:
    print(i)
# Judge status: Wrong Answer
N,A,B = map(int,input().split())
S = input()

pass_human = 0
overseas = 0

for i in S:
    if i == "a":
        if pass_human < A+B:
            print("YES")
            pass_human += 1
        else:
            print("NO")
    elif i == "b":
        if pass_human < A+B and overseas < B:
            print("YES")
            pass_human += 1
            overseas += 1
        else:
            print("NO")
    else:
        print("NO")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
a.sort()

tmp = a[0]
ans = []
for i in range(1,len(a)):
    if tmp == a[i]:
        ans.append(tmp)
    else:
        tmp = a[i]

ans = set(ans)
ans = list(ans)

if len(ans) < 2:
    print(0)
else:
    print(ans[len(ans)-1]*ans[len(ans)-2])
# Judge status: Accepted
import sys
import math
import bisect

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

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=[ai//2 for ai in a]
# print(half_a)
lcm=half_a[0]
for i in range(n-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow_cnt=-1
tmp=half_a[0]
while tmp%2==0:
    pow_cnt+=1
    tmp=tmp//2
flag=True
for ai in half_a[1:]:
    if ai%(2**pow_cnt)!=0:
        flag=False
        break
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)
# Judge status: Accepted
def readinput():
    n=int(input())
    return n

def main(n):
    if n%2==1:
        return 0
    
    n=n//2
    count=0
    base=5
    while(base<=n):
        count+=n//base
        base*=5
    return count

if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)
# Judge status: Wrong Answer
N = int(input())

que = ['a']
res = []
for i in range(1, N):
    for q in que:
        res.append(q + 'a')
        res.append(q + 'b')
    que = res
    res = []
    
for q in que:
    print(q)
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
for i in range(n - 1):
    if a[i] & 1 and a[i + 1] > 0:
        a[i] -= 1
        a[i + 1] -= 1
        ans += 1
for i in range(n):
    ans += a[i] // 2


print(ans)
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    ans = 0
    cur = 0

    for char in S:
        if char == "I":
            cur += 1
        else:
            cur -= 1

        ans = max(ans, cur)

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
c=2
t=4
a=[]
val=0
v=0
flag=0
x,y = map(int, input().split())

for i in range(1,x+1):
    val=i*c
    v=i*t
    a.append(val)
    a.append(v)

if y in a:
    flag=1
if y==(x*c):
    flag=1
if y==(x*t):
    flag=1
    
if flag==1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, M = tuple(map(int, input().split()))
cnt = [0 for _ in range(N+1)]
for _ in range(M):
    fr, to = tuple(map(int, input().split()))
    cnt[fr] += 1
    cnt[to] += 1
for i in range(1, N+1):
    print(cnt[i])
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())

total=0
count=0

for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            total=500*l + 100*m + 50*n
            if(total==X): count += 1
                
print(count)
# Judge status: Accepted
a,b,c=map(int,input().split())
d=max(a,b,c)
if a%2==0 or b%2==0 or c%2==0:
  print(0)
elif a%2==1 and b%2==1 and c%2==1 and d==a:
  print(b*c)
elif a%2==1 and b%2==1 and c%2==1 and d==b:
  print(a*c)
elif a%2==1 and b%2==1 and c%2==1 and d==c:
  print(b*a)
# Judge status: Wrong Answer
a,b,c,k = map(int,input().split())
print(a-b)
# Judge status: Accepted
N = (int)(input())
if N%9==0:
  print('Yes');
else:
  print('No')
# Judge status: Accepted
r, g, b = map(str, input().split())
if int(r+g+b)%4==0:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N,M = map(int,input().split())
A = [1 for _ in range(N+1)]
B = [0 for _ in range(N+1)]
B[1] = 1
cnt = 1
for _ in range(M):
    a,b = map(int,input().split())
    if B[a]==1 and A[a]>0:
        A[a] -= 1
        if A[a]==0:
            cnt -= 1
        A[b] += 1
        if B[b]==0:
            B[b]=1
            cnt += 1
print(cnt)
# Judge status: Wrong Answer
from numpy import array

n,m,x=map(int,input().split())


c=[]
d=[0]*(m+1)
for i in range(n):
    c1=array(list(map(int,input().split())))
    c.append(c1)
    d+=c1


#print(c)
#c.sort(key=lambda x: x[0], reverse=True)
#print(c)
#print(d)

if(False in [x<=i for i in d[1:]]):
   print(-1)
   exit()

#print(d[0])

for i in range(n):
    e=d-c[i]
    #print(e)
    if(False not in [x<=i for i in e[1:]]):
        d=e

print(d[0])
# Judge status: Wrong Answer
n = int(input())
*a, = map(int, input().split())
th = 1e18

mul = 1
for i in range(n):
    mul *= a[i]
    if mul >= th:
        print(-1)
        exit()
print(mul)
# Judge status: Accepted
# C - Walk on Multiplication Table
# https://atcoder.jp/contests/abc144/tasks/abc144_c

import math

n = int(input())
sqr = int(math.sqrt(n)) + 1
for i in range(sqr, 0, -1):
         if (n % i) == 0:
            print(i + (n//i) - 2)
            exit()
# Judge status: Accepted
s = input()
t = input()
ans = 10000
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt = cnt + 1
    ans = min(ans,cnt)

print(ans)
# Judge status: Accepted
s = list(input())
n = len(s)
count = 0

for i in range(n):
  if s[i] == "1":
    count = count + 1
    
ans = min((n-count),count)*2
print(ans)
# Judge status: Accepted
X = int(input())
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

while(is_prime(X)!= True):
    X +=1
print(X)
# Judge status: Wrong Answer
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]

h = sorted(h)
diff = [h[i + 1] - h[i] for i in range(n - 1)]
diff = sorted(diff)

ans = sum(diff[:k - 1])
print(ans)
# Judge status: Accepted
def frog(l,n):
  dp=[0]*n
  dp[0]=0
  dp[1]=abs(l[1]-l[0])
  for i in range(2,n):
    dp[i]=min(dp[i-1]+ abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2]))
  return dp[n-1]
n=int(input())
l=list(map(int,input().split()))
print(frog(l,n))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = A[i] % 4
if A.count(2) % 2 == 0:
    if A.count(0) * 2 >= (A.count(1)+A.count(3)):
        print("Yes")
    else:
        print("No")
else:
    if A.count(0) * 2 >= (A.count(1)+A.count(3)) + 1:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
a, b = map(int, input().split())
s = list(input())
num = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
cnt = 0
if s[a] != "-":
  print("No")
  exit()
else:
  s.pop(a)
for i in s:
  for j in num:
    if i == j:
      cnt += 1
if cnt != len(s):
  print("No")
  exit()
print("Yes")
# Judge status: Accepted
import math
n, m = map(int, input().split())

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
#print(b)

for i in range(len(b)):
    if b[i] * n <= m:
        a.append(b[i])
#print(a)

if len(b) == 2:
    print(1)
else:
    print(max(a))
# Judge status: Wrong Answer
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
for i in range(X+1,Y+1,1):
    if i <= y[0] and i > x[-1]:
        print("No war")
        break
else:
    print("War")
# Judge status: Accepted
import math
N = int(input())

answer = N+1
i = int(math.sqrt(N))
while i > 0:
    if N % i == 0:
        answer = i + N // i
        break
    i -= 1
print(answer-2)
# Judge status: Wrong Answer
a,b = map(int,input().split())
if (a+b) % 2 == 0:
  print((a+b)/2)
else:
  print("IMPOSSIBLE")
# Judge status: Accepted
x,n = map(int,input().split())
p = list(map(int,input().split()))
tmp = []
for i in range(-101,102):
    tmp.append(i)

if n == 0:
    print(x)
else:
    for i in p:
        tmp.remove(i)
    
    ans = []
    for i in tmp:
        a = abs(x-i)
        ans.append(a)
 
    b = min(ans)
    
    c = x+b
    d = x-b
 
    if c and d in tmp:
        print(d)
    elif c in tmp:
        print(c)
    elif d in tmp:
        print(d)
# Judge status: Accepted
from collections import Counter
s=input()
t=input()

sc=Counter(s)
tc=Counter(t)
if len(sc)!=len(tc):
  print("No")
else:
  for s1,t1 in zip(sorted(sc.items(),key=lambda i: i[1]),sorted(tc.items(),key=lambda i: i[1])):
    if s1[1]!=t1[1]:
      print("No")
      break
  else:
    print("Yes")
# Judge status: Accepted
l1 = input().split()
a = int(l1[0])
b = int(l1[1])
x = int(l1[2])
if x == a:
    print("YES")
for i in range(1,b+1):
    if x == a+i:
        print("YES")
        exit()
if x < a or (x > (a+b)):
    print("NO")
# Judge status: Accepted
N, W = map(int, input().split())
w = {}
v = {}

for i in range(N):
    w[i+1], v[i+1] = map(int, input().split())

dp = {}
dp[0] = {}

for i in range(W+1):
    dp[0][i] = 0

for i in range(1, N+1):
    dp[i] = {}
    for j in range(0,W+1):
        if j >= w[i]:
            dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N][W])
# Judge status: Accepted
n = input()

n = n[:3]
print(n)
# Judge status: Wrong Answer
s = list(input())
k = int(input())
#print(ord("z"))
for i in range(len(s)):
  if 123 - ord(s[i]) <= k:
    k -= (123 - ord(s[i]))
    s[i] = 'a'
    #print(k)
#print(s, k)
k %= 26
if ord(s[-1]) + k > 122:
  s[-1] = chr(ord(s[-1]) + k - 26)
else:
  s[-1] = chr(ord(s[-1]) + k)
ans = ""
for i in s:
  ans += i
print(ans)
# Judge status: Accepted
from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 != 0:
    b.reverse()

b = list(b)

for i in range(len(b)-1):
    print(b[i],end = " ")
print(b[-1])
# Judge status: Accepted
num = int(input())
count = 0
for i in range(num):
    if (i + 1) % 15 == 0:
        pass
    elif (i + 1) % 3 == 0:
        pass
    elif (i + 1) % 5 == 0:
        pass
    else:
        count += i + 1
print(count)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ab = [abs(i) for i in a]
cnt = 0
for i in a:
    if i < 0:
        cnt += 1
if 0 in a or cnt % 2 == 0:
    print(sum(ab))
else:
    print(sum(ab) - min(ab) * 2)
# Judge status: Wrong Answer
import sys
stdin = sys.stdin
import copy

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
if n % 2 != 0:
    print(0)
else:
    n2 = copy.copy(n)
    n5 = copy.copy(n)
    c2, c5 = 0, 0
    while n2 > 1:
        n2 //= 2
        c2 += n2
    while n5 > 1:
        n5 //= 5
        c5 += n5//2
    print(c2, c5)
    print(min(c2, c5))
# Judge status: Accepted
N=int(input())
x=0
for n in range(1,N):
  x+=(N-1)//n
print(x)
# Judge status: Wrong Answer
n, d = map(int, input().split())
l=[0]*n
for i in range(n):
  l[i] = list(map(int, input().split()))
print(l)
# Judge status: Accepted
A = int(input())
B = int(input())

for i in range(1,4):
    if (i != A)and(i != B):
        print(i)
# Judge status: Accepted
h, n = map(int, input().split())
if sum(list(map(int, input().split()))) >= h:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
res=""
while n!=0:
    mod=n%26
    n=n//26
    if mod==0:
        mod=26
        n-=1
    res+=chr(97+mod-1)
print(res[::-1])
# Judge status: Accepted
#120_B
A,B,K=map(int,input().split())

from fractions import gcd

x=gcd(A,B)
cnt=0
for i in range(x,0,-1):
    if x%i==0:
        cnt+=1
    if cnt==K:
        print(i)
        exit()
# Judge status: Accepted
n,l=map(int,input().split())
list=[]
for _ in range(n):
    list.append(input())
 
list.sort()
ans=""
for i in list:
    ans+=i
print(ans)
# Judge status: Wrong Answer
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N, K = mapint_inp()
MOD = 10*9+7

ans = 0
for i in range(K, N+2):
    mn = i*(i-1) // 2
    mx = i*(2*N-i+1) // 2
    ans += mx - mn + 1

print(ans%MOD)
# Judge status: Accepted
x = int(input())
result = (x-1)//11*2+1
if (x-1)%11 >5:
  result += 1
  
print(result)
# Judge status: Wrong Answer
W, H, x, y = map(int, input().split())

if x == W / 2 and y == H / 2:
    print(W*H/2, 1)
    exit()

if x == y == 0 or (x == W and y == 0) or (x == 0 and y == H) or (x == W and y == H):
    print(W*H/2, 0)
    exit()

if abs(x-W/2) < abs(y-H/2):
    ans = min(x, W-x) * H
else:
    ans = W * min(y,H-y)

print(ans, 0)
# Judge status: Accepted
import itertools

n = int(input())
p_li = tuple(map(int, input().split()))
q_li = tuple(map(int, input().split()))

n_li = [ i for i in range(1, n+1)]

s = list(itertools.permutations(n_li, len(n_li)))
s.sort()

p = 0
q = 0

for i in range(len(s)):
    if s[i] == p_li:
        p = i
    if s[i] == q_li:
        q = i

print(abs(p-q))
# Judge status: Accepted
a,b,c,d,e=map(int,input().split())
print(c*60+d-a*60-b-e)
# Judge status: Accepted
n = str(input().split())

ans = 0
for i in range(len(n)):
    if n[i] == "7":
        ans = 1
        
if ans == 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
S = input()
ans = 0
for i in range(N):
  ans = max(ans,len(set(S[:i])&set(S[i:])))
print(ans)
# Judge status: Accepted
N = input()[-1]
if N in ['2', '4', '5', '7', '9']:
  print('hon')
elif N in ['0', '1', '6', '8']:
  print('pon')
else:
  print('bon')
# Judge status: Accepted
n = int(input())
a = [int(input()) for i in range(n)]

c = 0

for i in range(n-1):
  if a[i]%2 == 1 and a[i+1]>=1:
    c += 1
    a[i] -= 1
    a[i+1] -= 1
for i in range(n):
  c += a[i]//2
  a[i] -= (a[i]//2)*2
print (c)
# Judge status: Wrong Answer
n = int(input())
ans = 0
for k in range(1, n + 1):
  m = n / k
  mc2 = (m * (m + 1)) / 2
  ans += mc2 * k
print(ans)
# Judge status: Wrong Answer
import math

S = list(input())
ls = len(S)
na = S.count("a")
nb = S.count("b")
nc = ls - na - nb
mi = min(na, nb, nc)

if ls == 1:
    print("YES")
    exit()
elif ls == 2:
    if S[0] == S[1]:
        print("NO")
    else:
        print("YES")

temp = math.ceil(ls / 4)
if mi >= temp:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
import math

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

s = 0

for i in range(1, N + 1):
    if K > i:
        s += 1 / math.pow(2, math.ceil(math.log2(K)) - math.ceil(math.log2(i)))
    else:
        s += 1

print(s / N)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
h = int(input())

print((a+b) * h / 2)
# Judge status: Wrong Answer
X = int(input())

if X == 7 or X == 5 or X == 3:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())

def f(s):
    if len(s) == N:
        print(s)
        return
    for i in range(97, ord(max(list(s)))+1+1):
        ns = s + chr(i)
        f(ns)

f('a')
# Judge status: Accepted
import heapq

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

B_pool = 0
deck = []
for i in range(N):
	heapq.heappush(deck, A[i]-B[i])

while deck:
	diff = heapq.heappop(deck)
	if diff <= 0:
		B_pool += (-diff) // 2
	else:
		B_pool -= diff

if B_pool >= 0:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
S = input()
data_list = S.split()
ab_distance = abs(int(data_list[0])-int(data_list[1]))
ac_distance = abs(int(data_list[0])-int(data_list[2]))
bc_distance = abs(int(data_list[1])-int(data_list[2]))
d = int(data_list[3])
if ac_distance <= d:
    print('Yes')
elif ab_distance <= d and bc_distance <= d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from collections import defaultdict
d = defaultdict(str)
k = defaultdict(str)

S = input()
T = input()

ans = "Yes"

for i in range(len(S)):
  if d[S[i]] and d[S[i]] != T[i]:
    ans = 'No'
    break

  if k[T[i]] and k[T[i]] != S[i]:
    ans = 'No'
    break

  d[S[i]] = T[i]
  k[T[i]] = S[i]

print(ans)
# Judge status: Accepted
s=input()
l=len(s)
while s!=0:
    l=len(s)
    if s.rfind("dream")==l-5:
        s=s[:l-5]
    elif s.rfind("dreamer")==l-7:
        s=s[:l-7]
    elif s.rfind("erase")==l-5:
        s=s[:l-5]
    elif s.rfind("eraser")==l-6:
        s=s[:l-6]
    else:
        break
if len(s)==0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer

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

s = S[0]
count = 0
k = 0
for i in range(1, len(S)):
    #print(S[i], s)
    if s == S[i]:
        count += 1
    else:
        s = S[i]
        k += 1
        
count += K * 2
if K == k // 2 + 1:
    count -= 1
print(count)
# Judge status: Wrong Answer
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
  S = input()
  if S == 'AC':
    ac += 1
  elif S == 'WA':
    wa += 1
  elif S == 'TLE':
    tle += 1
  elif S == 'RE':
    re += 1
  else:
    break

print('AC ×',ac)
print('WA ×',wa)
print('TLE ×',tle)
print('RE ×',re)