peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,k=map(int, input().split())
a=list(map(int, input().split()))
b=[False]*n
pos=0
for i in range(min(n,k)):
    if b[pos]!=False:
        loop=i-b[pos]+1
        break
    b[pos]=i+1
    pos=a[pos]-1
    k-=1
if k>0:
    for i in range(k%loop):
        pos=a[pos]-1
print(pos+1)
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [1]
C = [1] + [0] * (N - 1)
i = 0

while C[A[i] - 1] == 0:
    B.append(A[i])
    C[A[i] - 1] = 1
    i = A[i] - 1

ans = 0
for j in range(len(B)):
    if B[j] == A[i]:
        ans += j

if (len(B) - ans != 0) and (K - ans > 0):
    ans += (K - ans) % (len(B) - ans)

print(B[ans])
# Judge status: Accepted
from math import floor
from decimal import Decimal

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

num = A
c = 0
while num <= B:
    num *= 2
    c+=1

print(c)
# Judge status: Wrong Answer
S, W = map(int, input().split())

if S/2 < W:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted
N = int(input())
S = [input() for _ in range(N)]

print(len(set(S)))
# Judge status: Accepted
n = int(input())
num = list(map(int, input().split()))

ans = 1
if 0 in num:
    print(0)
    exit()
else:
    for i in num:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()

print(ans)
# Judge status: Accepted
def main():
    import sys
    import bisect
    from itertools import accumulate

    n = int(input())
    a = list(map(int, sys.stdin.readline().split()))

    b = list(accumulate(a))
    l = b[-1]
    i = bisect.bisect(b, l // 2)
    ans = min(abs(l - 2 * b[i - 1]), abs(l - 2 * b[i]))
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
# -*- coding: <encoding name> -*-

d = int(input())
# print('Chrestmas' if d == 25 else 'Chrestmas Eve' if d == 24)
print('Chrestmas' + ' Eve' * (25 -d))
# Judge status: Wrong Answer
S = str(input())
ans = ''
ans2 = ''
con = 0
for s in S:
  ans += s
  if s != ans2:
    if ans != ans2:
      con += 1
      ans2 = ans
      ans = ''
print(con)
# Judge status: Accepted
x=int(input())

if x>=30:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from collections import Counter

N,M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for i in range(M):
    AB.append(list(map(int, input().split())))

l = [True]*N

for m in AB:
    if H[m[0]-1] == H[m[1]-1]:
        l[m[0]-1] = False
        l[m[1]-1] = False
    elif H[m[0]-1] > H[m[1]-1]:
        l[m[1]-1] = False
    else:
        l[m[0]-1] = False

print(Counter(l)[True])
# Judge status: Wrong Answer
q,h,s,d=map(int,input().split())
n=int(input())
l=min(q*n*4,h*n*2,s*n,d*n/2)
if l != d*n/2:
    print(l)
else:
    m=min(q*4,h*2,s)
    print((d*(n-1)/2)+m if n%2==1 else l)
# Judge status: Accepted
N,M,X = map(int,input().split())
array = [ list(map(int,input().split())) for _ in range(N) ]
ans = 10**18
for i in range ( 2**N ):
  price = 0
  skill = [0]*M
  count = 0
  for k in range(N):
    if ( i >> k ) & 1:
      price += array[k][0]
      for j in range (M):
        skill[j] += array[k][j+1]
  for t in range(M):
    if skill[t] < X:
      break
    else:
      count += 1
    if count == M:
      ans = min(price,ans)
      
print( -1 if ans == 10**18 else ans)
# Judge status: Accepted
n = int(input())
pp = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    if pp[i] == i + 1:
        pp[i], pp[i+1] = pp[i+1], pp[i]
        cnt += 1
if pp[n-1] == n:
    cnt += 1
print(cnt)
# Judge status: Accepted
s = input()

x = len(s)

cnt = 1

ans = 0

for i in s:
    if cnt == 1:
        cnt = 0
        if i != "L":
            ans += 1
    else:
        cnt = 1
        if i != "R":
            ans += 1

if ans == x:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
trans = sorted(list(int(input()) for _ in range(5)))

if n > trans[0]:
    ans = n // trans[0] + 5
    print(ans)
else:
    print(5)
# Judge status: Accepted
n = int(input())
h = [int(x) for x in input().split()]

for i in reversed(range(1, n)):
    if h[i - 1] > h[i]:
        h[i - 1] -= 1

flg = True
for i in range(n - 1):
    if h[i] > h[i + 1]:
        flg = False
        break
        
if flg:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input()
g = set(s)
if('A' in g and 'B' in g):
  print('Yes')
else:	print('No')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

ans = 'NO'
total = 0
if a < b and c%a == 0:
  ans = 'YES'
else:
  for i in range(1, 100000):
    total += a*i
    if total%b == c:
      ans = 'YES'
      break
  
print(ans)
# Judge status: Wrong Answer
def DiscountFare(x , y):

    return x + (y / 2)

def main():
    x , y = map(int , input().split())
    print(DiscountFare(x , y))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
input_ = list(map(str, input().split()))

number = int(input_[0] + input_[1])

for i in range(400):
    if i**2 is number:
        print('Yes')
        break
    elif i**2 > number:
        print('No')
        break
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
    one = 0
    for j in range(n):
        if (a[j] >> i) & 1:
            one += 1
    ans = (ans + (one*(n-one))*two) % mod
    two = (two * 2) % mod
print(ans)
# Judge status: Accepted
N = int(input())
S = input()
a = 0
b = S.count('.')
num = min(N - b, b)
for i in range(N):
  x = S[i] =='#'
  a += x
  b -= 1-x
  num = min(num, a+b)
print(num)
# Judge status: Accepted
a, b, c = [int(_) for _ in input().split()]
if a + c == 2 * b:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
s = str(input())
A = [0,0,0]
for a in s:
  if a=='a':A[0]+=1
  if a=='b':A[1]+=1
  if a=='c':A[2]+=1

if max(A)-min(A)>=2:
  print("NO")
else:
  print("YES")
# Judge status: Accepted
x = int(input())
if x%2 != 1:
  print(x//2)
else:
  print(x//2+1)
# Judge status: Accepted
N = int(input())

odd = list()

count_list = list()
count = 0

for a in range(1, N+1):
    if a % 2 != 0:
        odd.append(a)

l = len(odd)

for a in range(0, l):
    for b in range(1, odd[a]+1):
        if odd[a] % b == 0:
            count += 1
    count_list.append(count)
    count = 0

print(len(list(filter(lambda x: x == 8, count_list))))
# Judge status: Wrong Answer
from math import gcd

a, b, k = map(int, input().split())
x = gcd(a, b)
for i in range(1, x+1):
  cnt = 0
  if x % i == 0:
    if cnt == k-1:
      print(i)
      break
    else:
      cnt += 1
# Judge status: Wrong Answer
S = input()
K = int(input())

oz = ord("z")

ans = ""

for s in S[:-1]:
    if K==0:
        break
    if oz+1-ord(s) <= K:
        K -= oz+1-ord(s)
        ans += "a"
    else:
        ans += s

ans += chr(((ord(S[-1])-ord("a")+K)%26)+ord("a"))

print(ans)
# Judge status: Accepted
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
ans=0
if N<=K:
    ans=N*X
else:
    ans=K*X+(N-K)*Y
print(ans)
# Judge status: Accepted
a, b, c=map(int, input().split())
print(max(c-(a-b), 0))
# Judge status: Accepted
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
A.insert(0,0)
for i in range(len(A)-1):
  s = A[i] + A[i+1]
  if s > x:
    diff = min(s - x, A[i+1])
    A[i+1] -= diff
    ans += diff
  
print(ans)
# Judge status: Wrong Answer
N, X,T= map(int, input().split())
while(X<N):
    X=X*2
    T=T*2
print(T)
# Judge status: Accepted
from collections import Counter

n = int(input().strip())

cnt = Counter()
result = 0
for i in range(1, n + 1):
    s = str(i)
    result += cnt[s[-1], s[0]] * 2
    if s[0] == s[-1]:
        result += 1
    cnt[s[0], s[-1]] += 1
print(result)
# Judge status: Accepted
from sys import stdin

A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]  # 空白区切り

if abs(A - C) <= D or (abs(A - B) <= D and abs(B - C) <= D):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,C,K = map(int,input().split())

T = sorted(int(input()) for _ in range(N))


i = 0
bus = 0
while i < N:
    bus += 1
    c = 0
    limit = T[i]+K
    while c < C and i < N and T[i] <= limit:
        c += 1
        i += 1

print(bus)
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [list(map(int,input().split())) for i in range(M)]

minPrice = min(a) + min(b) #割引額を考慮しない最小金額
price = 0

for x in range(len(c)):
    price = a[c[x][0]-1] + b[c[x][1]-1] - c[x][2]
    if minPrice > price:
        minPrice = price
    price = 0

print(minPrice)
# Judge status: Accepted
n, k = map(int, input().split())
score = list(map(int, input().split()))
t = input()
self = [0] * n
for i in range(n):
    if t[i] == 'r':
        self[i] = 2
    elif t[i] == 's':
        self[i] = 0
    elif t[i] == 'p':
        self[i] = 1
    if i >= k and self[i] == self[i - k]:
        self[i] = 3
ans = 0
for x in self:
    if x != 3:
        ans += score[x]
print(ans)
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
cost=list(map(int,input().split()))

for i in range(4):
    cost[i]/=2**(i-2)

N=int(input())


if min(cost)==cost[3]:
    print(int((N//2*2)*cost[3]+(N%2)*min(cost[:3])))
else:
    print(int(min(cost)*N))
# Judge status: Wrong Answer
N=int(input())
S=input()
stack= []
ans=""

for i in range(N):
  if S[i]=="(":
    stack.append(S[i])
  else:
    if len(stack)>0:
      ans = stack.pop()+ ans + ")"
    else:
      ans = "(" + ans + ")"

nokori=len(stack)
ans = nokori * "(" + ans + nokori * ")"

print(ans)
# Judge status: Wrong Answer
n = int(input())
A = []
for i in range(n):
  A.append(int(input()))
m = n
t = 0
B = [0]
while B != []:
  B = []
  for i in range(m-1):
    if A[i] >= A[i+1]:
      B.append(A[i+1])
  A = B
  t += 1
  m = len(B)
print(t)
# Judge status: Accepted
from functools import reduce
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)
def lcm_all(A):
    return reduce(lcm, A, 1)

n, M = map(int, input().split())
A = set(map(lambda x: int(x)//2, input().split()))

scm_core = lcm_all(A)

canmake_scm = True
for a in A:
    if scm_core // a % 2 == 0:
        canmake_scm = False
        break

if canmake_scm:
    print(((M // scm_core)+1) // 2)
else:
    print(0)
# Judge status: Wrong Answer
N = int(input())
S = str(input())

if ')' in S:
  for i in range(N):
    if S[N-1-i] == ')':
      n = N-i
      break
  lc = S[:n].count('(')
  rc = S[:n].count(')')
  if rc > lc:
    S = (rc-lc) * '(' + S

s = S.index('(')
l = S[s:].count('(')
r = S[s:].count(')')
if l > r:
  S = S + (l-r) * ')'
  
print(S)
# Judge status: Accepted
from collections import Counter, defaultdict
n = int(input())
lc = [chr(i) for i in range(97, 97+26)]
ans_dict = Counter(input())

for _ in range(n-1):
    S = input()
    tmp = {k:0 for k in lc}
    for s in S:
        tmp[s] += 1

    for k in tmp.keys():
        try:
            ans_dict[k] = min(ans_dict[k], tmp[k])
        except:
            pass

ans = ''
for k, v in sorted(ans_dict.items()):
    ans += k * v
print(ans)
# Judge status: Wrong Answer
a = input()
b = []
for i in range(int(a[0])):
    b.append(input())
b.sort()
for j in b:
    print(j, end = "")
print("")
# Judge status: Accepted
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
ans=0
for i in range(n):
    tmp = s.count(s[i])-t.count(s[i])
    ans=max(ans,tmp)
print(ans)
# Judge status: Accepted
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)

a,b=map(int,input().split())
g=gcd(a,b)
print((a*b)//g)
# Judge status: Accepted
#!/usr/bin/env python3

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

if A < B < C:
    print('Yes')
    exit()

while K > 0:
    if A >= B:
        B *= 2
    elif B >= C:
        C *= 2

    K -= 1


if A < B < C:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n, m = map(int, input().split())
list = [[0 for i in range(n)] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    list[a-1][b-1] = 1
    list[b-1][a-1] = 1
for ll in list:
    if ll == [0]*n:
        print('No')
        break
else:
    print('Yes')
for ll in list:
    for j in range(len(ll)):
        if ll[j] == 1 and ll != list[0]:
            print(j+1)
            continue
# Judge status: Accepted
ans = 0
s = 9
flag = True
for i in range(5):
    n = int(input())
    if n%10 != 0:
        s = min(s,n%10)
        ans += n//10+1
        flag = False
    else:
        ans += n//10
else:
    if flag:
        print(ans*10)
    else:
        print((ans-1)*10+s)
# Judge status: Wrong Answer
h,n=map(int,input().split())
H=[]
A=[]
for i in range(n):
    a,b=map(int,input().split())
    H.append([a,b])
    A.append(a)
a_max=max(A)
dp=[10**5]*(h+a_max+1)
dp[0]=0
for i in range(1,h+a_max+1):
    for j in range(n):
        if i-H[j][0]<0:
            continue
        dp[i]=min(dp[i],dp[i-H[j][0]]+H[j][1])
print(min(dp[h:h+a_max+1]))
# Judge status: Wrong Answer
N = int(input())
S = list(input())

Lw = 0
Re = S.count("E")
ans_lst = [Lw+Re]*(N)

# i+1をリーダーとみなす
for i in range(1,N):
    if S[i-1] == "W":
        Lw += 1
    else:
        Re -= 1
    ans_lst[i] = Lw + Re

ans = min(ans_lst)
print(ans)
# Judge status: Wrong Answer
s = input()

if s.isupper():
    print("A")
else:
    print("B")
# Judge status: Accepted
n,r=map(int,input().split())
if 10<=n:
    print(r)
if n<10:
    print(r+(100*(10-n)))
# Judge status: Accepted
from itertools import permutations

n = int(input())
itr = permutations([i for i in range(1, n+1)])
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

for i, tpl in enumerate(itr):
    if tpl == p:
        val1 = i
    if tpl == q:
        val2 = i

print(abs(val1-val2))
# Judge status: Wrong Answer
from collections import Counter
MOD = 10*9 + 7
N = int(input())
S = input()
count_si = Counter(S)
ans = 1
for v in count_si.values():
    ans = (ans * (v+1)) % MOD

if ans == 0:
    print(MOD-1)
else:
    print((ans-1)%MOD)
# Judge status: Accepted
# -*- coding: utf-8 -*-

def main():

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

    ans = 0

    if K <= A:
        ans = K

    else:
        if K <= A + B:
            ans = A

        else:
            ans = A + (-1 * (K - A - B))

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N, M = map(int, input().split())
mini = 0
maxi = N
for i in range(M):
  L, R = map(int, input().split())
  mini = max(mini, L)
  maxi = min(maxi, R)
print(maxi - mini + 1 if maxi - mini + 1 > 0 else 0)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
b = list(map(int, input().split()))
for i in range(n):
    if b[i] >= a[i]:
        b[i] -= a[i]
        a[i] = 0
    else:
        a[i] -= b[i]
        continue
    a[i + 1] -= b[i]
    if a[i + 1] < 0:
        a[i + 1] = 0

if a[-1] < 0:
    a[-1] = 0
print(sum_a - sum(a))
# Judge status: Accepted
from collections import Counter

n = int(input())
l = list(map(int, input().split()))
c = Counter(l)
s = set(l)
ans = 0

for i in s:
    ans = max(c[i-1] + c[i] + c[i+1], ans)
print(ans)
# Judge status: Accepted
n = int(input())
cuisine = list(map(int, input().split()))
saticefaction = list(map(int,input().split()))
moreSaticefaction = list(map(int, input().split()))
total = 0
beforeCuisine = -1
for i in cuisine:
  total += saticefaction[i - 1]
  if (i - 1) == beforeCuisine:
    total += moreSaticefaction[beforeCuisine - 1]
  beforeCuisine = i
print(total)
# Judge status: Accepted
x = int(input())
ans = x//11*2
if x % 11 > 0: ans+=1
if x % 11 > 6: ans+=1
print(ans)
# Judge status: Wrong Answer
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N):
  dist = min(dist, W[i]-W[i-1])
print(dist)
# Judge status: Accepted
N, K = map(int,input().split())
dices = list(map(int,input().split()))
list =[]
check=0
for i in range(K):
    check+=dices[i]
list.append(check)
for j in range(N-K):
    check -= dices[j]
    check += dices[j+K]
    list.append(check)    
print((max(list)+K)/2)
# Judge status: Accepted
def main():
    number_of_person = int(input())
    array = [int(x) for x in input().split()]
    pre_h = 0
    step_total = 0
    for height in array:
        step_total += max(pre_h - height, 0)
        pre_h = max(height, pre_h)
    return step_total


if __name__ == '__main__':
    ans = main()
    print(ans)
# Judge status: Accepted
used = set()
S = input()
for s in S:
    if s in used:
        ans = 'no'
        break
    used.add(s)
else:
    ans = 'yes'
print(ans)
# Judge status: Wrong Answer
S = list(input())
L = len(S)
key = list("keyence")
if S[0:7] == key:
    print("YES")
    exit()

if S[L-7:] == key:
    print("YES")
    exit()

for i in range(1,6):
    if S[0:i] == key[0:i] and S[L-7+i:] == key[i:]:
        print("YES")
        exit()
print("NO")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
dp = [[0]*2 for _ in range(n+1)]
dp[0][1] = -10**9
for i in range(n):
    for j in range(2):
        dp[i+1][1-j] = max(dp[i+1][1-j],dp[i][j]+(-1)**(j+1)*a[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j]+(-1)**j*a[i])
print(dp[n][0])
# Judge status: Accepted

n = int(input())
a = list(map(int, input().split()))
calc = []
for i in range(n):
    calc.append(a[i] - (i + 1))

calc.sort()
b = calc[n // 2]
ans = 0
for i in range(n):
    ans += abs(a[i] - (b + i + 1))

print(ans)
# Judge status: Accepted
n = int(input())
p = [50 for i in range(26)]
for i in range(n):
    kar = input()
    for i in range(26):
        p[i] = min(p[i],kar.count(chr(ord("a") + i)))
for i in range(26):
    for j in range(p[i]):
        print(chr(ord("a") + i),end="")
# Judge status: Accepted
A,B,C=map(int, input().split())
print("Yes" if A<=C<=B else "No")
# Judge status: Accepted
Q, H, S, D = map(int, input().split())   # 0.25, 0.5, 1.0, 2.0
N = int(input())

if N%2==0:
    kijun1 = min(Q*8, H*4, S*2, D)
    print(N//2 * kijun1)
else:
    kijun1 = min(Q*8, H*4, S*2, D)
    kijun2 = min(Q*4, H*2, S)
    print(N//2 * kijun1 + kijun2)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
x=0
y=0
z=0
for i in range(n):
    if a[i]%4==0:
        x+=1
    elif a[i]%2==0:
        y+=1
    else:
        z+=1
if y==0:
    if z<=x+1:
        print("Yes")
    else:
        print("No")
else:
    if z<=x:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    S = input().strip()
    if len(S) != 6:
        return "No"
    if S[2] == S[3] and S[4] == S[5]:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())
# Judge status: Accepted
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
ans = 0
for e in c:
  if e < c[e]:
    ans += c[e] - e
  elif e > c[e]:
    ans += c[e]
print(ans)
# Judge status: Accepted
S = input()
if S[0] == S[1] == S[2]:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))

max=0
cnt=0
for i in range(N):
    if max-H[i]>=2:
        print('No')
        break
    else:
        cnt+=1
        if H[i]>max:
            max=H[i]
if cnt==N:
    print('Yes')
# Judge status: Accepted
x,y=map(int,input().split())

def nCr(n,r,mod=10**9+7):
    r=min(r,n-r)
    a=b=1
    for i in range(1,r+1):
        a=a*n%mod
        b=b*i%mod
        n-=1
    return a*pow(b,mod-2,mod)%mod

z=x+y
if z%3!=0 or x-(z//3)<0 or y-(z//3)<0:
    print(0)
else:
    z//=3
    # print(z)
    # print(min(x,y)-z)
    print(nCr(z,min(x,y)-z))
# Judge status: Accepted
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)
c = 0
for i in range(N-1,-1,-1):
    if (A[i]+c) % B[i] == 0:
        continue
    if A[i]+c < B[i]:
        push = B[i] - (A[i]+c)
    elif A[i]+c > B[i]:
        push = B[i] - (A[i]+c) % B[i]
    c += push
print(c)
# Judge status: Accepted
N, M = [int(x) for x in input().split()]
a = set(int(input()) for _ in range(M))
 
MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1#二段目の調節　0段目の場合の数
 
for i in range(1, N + 1):
  if i in a:
    continue
  x = dp[i - 1]
  if i > 1:
    x += dp[i - 2]
  dp[i] = x % MOD

ans = dp[N]
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = input()
r_num = s.count('R')
g_num = s.count('G')
b_num = s.count('B')
tot = r_num*g_num*b_num
print(tot)
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)

        if k<n:
            if s[i]!=s[j] and s[i]!=s[k] and s[j] != s[k]:
                tot -= 1

print(tot)
# Judge status: Wrong Answer
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    s = i = 0
    while True:
        i += 1
        s = (s*10 + 7) % k
        if s % k == 0:
            print(i)
            break
# Judge status: Accepted
A,B,C = map(int, input().split())

if A<= C<= B:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s = input()

def check(s):
    flag = True
    for i in range(len(s)):
        if s[i] != s[-i-1]:
            flag = False
    return flag

s1 = s[:(len(s)-1)//2]
s2 = s[(len(s)+3)//2-1:]
# print(s1)
# print(s2)

if check(s) and check(s1) and check(s2):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()
t = input()
check = t[:-1]
a = len(s)
b = len(t) - 1
if a == b:
    if s == check:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
a, b = map(int, input().split())
s = input()

if s[a] != '-':
    print('No')
    exit()
try:
    int(s[:a])
    int(s[a + 1:])
except:
    print('No')
    exit()
print('Yes')
# Judge status: Wrong Answer
X=int(input()) #1200
a=X//500 #2
b=(X-500*a)//5  #
print(a+b)
# Judge status: Accepted
a,b = map(int,input().split())

if a < 0 and b < 0:
  if (b-a)%2 == 1:
    print('Positive')
  else:
    print('Negative')

elif a>0:
  print('Positive')

else:
  print('Zero')
# Judge status: Accepted
n,a,b = map(int,input().split())
s = input()

for c in s:
  if c =='c':
    print('No')
  elif c=='a':
    if a >0:
      print('Yes')
      a -= 1
    elif b > 0:
      print('Yes')
      b -= 1
    else:
      print('No')
  else:
    if b > 0:
      print('Yes')
      b -= 1
    else:
      print('No')
# Judge status: Accepted
N,K=map(int,input().split())
S=input()
S2=S.lower()
S3=''

for i in range(N):
  if i==K-1:
    S3+=S2[i]
  else:
    S3+=S[i]
    
print(S3)
# Judge status: Accepted
s=list(input())
s=s[::-1]
l=len(s)
mod=2019
count=[0]*2019
count[0]=1
num=0
seki=1
for i in range(l):
    num+=int(s[i])*seki
    num=num%mod
    count[num]+=1
    seki=(seki*10)%mod
ans=0
for i in range(2019):
    N=count[i]
    ans+=N*(N-1)//2
print(ans)
# Judge status: Accepted
from collections import Counter
n = int(input())
alphabet = Counter(input())
for i in range(n-1):
  s = Counter(input())
  for x in alphabet:
    if alphabet[x] > s[x]:
      alphabet[x] = s[x]
print("".join(sorted(alphabet.elements())))
# Judge status: Wrong Answer
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

m = []

for i in range(M):
    x, y, z = map(int, input().split())
    m.append([x, y, z])

m.sort(reverse = True,key = lambda x: x[2])


ans = 100000
if a[m[0][0]-1] + b[m[0][1]-1] - m[0][2] >= min(a) + min(b):
    ans = min(a) + min(b)
else:
    ans = a[m[0][0]-1] + b[m[0][1]-1] - m[0][2]

print(ans)
# Judge status: Accepted
import math
#from functools import reduce
# import math
# import itertools
# import statistics
# import numpy as np
# import collections
n = int(input())
# l, r = list(map(int, input().split()))
# b = list(map(int, input().split()))
print(n*2*math.pi)
# Judge status: Accepted
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
L, R = 0, A[-1]
while R - L > 1:
    mid = L + (R - L) // 2
    if sum([(a - 1) // mid for a in A]) <= K:
        R = mid
    else:
        L = mid
print(R)
# Judge status: Accepted
S = input()
l = len(S)
a = S.count('0')
print(2 * min(a, l - a))
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

an =0
ki=a[0]
for i in range(n-1):
    wk=a[i]-a[i+1]
    if wk<0:
        an+=abs(wk)
        ki-=wk
print(an)