peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys

S=input()
K=int(input())

for s in S[:min(len(S),K)]:
    if s=="1":
        pass
    else:
        print(s)
        sys.exit()
print(1)
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))

diff = sum(W)
for w in W:
    if diff > abs(diff-2*w):
        diff -= 2 * w
    else:
        break
print(abs(diff))
# Judge status: Accepted
N, M = map(int, input().split())
print(M*(M-1)//2 + N*(N-1)//2)
# Judge status: Accepted
a,b,c=map(int,input().split())
cnt=0
while a%2==b%2==c%2==0:
  a1=a//2
  b1=b//2
  c1=c//2
  a=b1+c1
  b=c1+a1
  c=a1+b1
  cnt+=1
  if a==2*a1 and b==2*b1 and c==2*c1:
    cnt=-1
    break
print(cnt)
# Judge status: Wrong Answer
X, Y = map(int, input().split())

cnt=1
while 2*X<Y:
	X*=2
	cnt+=1
print(cnt)
# Judge status: Wrong Answer
import numpy as np


def function(N, K, A):
    pre = [int(A[i]) for i in range(K)]
    for i in range(1, N-K+1):
        now = [int(A[i]) for i in range(i, K+i)]
        if np.prod(now) > np.prod(pre):
            print('Yes')
        else:
            print('No')
        pre = now


if __name__ == '__main__':
    numbers = input().split()
    N = int(numbers[0])
    K = int(numbers[1])
    A = input().split()
    function(N, K, A)
# Judge status: Wrong Answer
N, x = map(int, input().split())
a = list(map(int, input().split()))

# 小さい数から配っていくと子供の人数を最大化できる
a = sorted(a)

leftCandy = 0
childrenCnt = 0
for i in range(len(a)):
  leftCandy = x - a[i]
  if leftCandy >= 0:
    childrenCnt += 1

print(childrenCnt)
# Judge status: Accepted
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
l=[]

for i in range(N):
    ans=0
    for j in range(i+1):
        ans+=A1[j]
    for k in range(j,N):
        ans+=A2[k]
    l.append(ans)
print(max(l))
# Judge status: Accepted
X = input()
"""
Tの前にSがどれだけあるか？
TSSTTTSS
"""
s_cnt = 0
t_cnt = 0
cnt = 0
for s in X:
    if s == "S":
        s_cnt += 1
    if s == "T":
        t_cnt += 1
        if t_cnt <= s_cnt:
            cnt += 2
        else:
            s_cnt = 0
            t_cnt = 0


print(len(X) - cnt)
# Judge status: Accepted
N, M = map(int, input().split())

if N == M == 1:
    print (1)
elif N == 1 or M == 1:
    print (N * M - 2)
else:
    print ((N -2) * (M - 2))
# Judge status: Accepted
A, B = map(int, input().split())
if A == B:
  print('Draw')
else:
  print( 'Alice' if (A if A != 1 else A+13) > (B if B != 1 else B+13) else 'Bob')
# Judge status: Accepted
import math
A, B, C, D = map(int, input().split())

taka = math.ceil(A/D)
aoki = math.ceil(C/B)

if taka < aoki:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
alice = sum(a[::2])
bob = sum(a[1::2])
ans = alice - bob
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
hand = {"r": "p", "s": "r", "p": "s"}
score = {"r": r, "s": s, "p": p}
other = "o"
t = input()
hist = [other] * k

result = 0
for i, v in enumerate(t):
    i %= k
    if hist[i] != hand[v]:
        hist[i] = hand[v]
        result += score[hand[v]]
    else:
        hist[i] = other
print(result)
# Judge status: Accepted
# C - Sum of product of pairs
from itertools import accumulate


def main():
    N, *A = map(int, open(0).read().split())
    rev_cumsum = list(accumulate(reversed(A[1:])))[::-1]
    MOD = 10 ** 9 + 7
    res = sum(a * c for a, c in zip(A[:-1], rev_cumsum)) % MOD
    print(res)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
lst = list(input())
count = 0

if n % 2 == 0:
    for i in range(n // 2):
        if lst[i] == lst[i + n // 2]:
            count += 1

if count == n / 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A, B, C, X, Y = list(map(int, input().split()))

s1 = A * X + B * Y

s2 = C * max(X, Y) * 2

if X > Y:
    s3 = C * (Y * 2) + A * (X - Y)
elif Y > X:
    s3 = C * (X * 2) + B * (Y - X)
else:
    s3 = 10**10

print(min(s1, s2, s3))
# Judge status: Accepted
a,b,c,d = map(int, input().split())
A = set([i for i in range(a,b+1)])
B = set([i for i in range(c,d+1)])

print(len(A&B) if len(A&B)==0 else len(A&B)-1)
# Judge status: Wrong Answer
n = int(input())
a = input().split()
index = 1
dic = {}
list1 = []
for i in a:
  dic[i] = index
  index += 1
S = sorted(a)
for i in S:
  list1.append(dic[i])
print(*list1)
# Judge status: Wrong Answer
n = int(input())
ans = []
cnt = 0
for i in range(n):
    s = input()
    ans.append(s)
ans.sort()
for i in range(n-1):
    if ans[i]!=ans[i+1]:
        cnt+=1
print(cnt)
# Judge status: Accepted
n = int(input())
p = [int(i) for i in input().split()]
c = 0
minp = p[0]
for pi in p:
    if pi < minp:
        minp = pi
        c += 1
print(c+1)
# Judge status: Accepted
import sys

readline = sys.stdin.readline
N = int(readline())
A = []
B = []
for _ in range(N):
    x, y = map(int, readline().split())
    A.append(x-y)
    B.append(x+y)
print(max(max(A) - min(A), max(B) - min(B)))
# Judge status: Accepted
if __name__ == "__main__":
    a = (input())
    if a[2]==a[3] and a[4]==a[5]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n, k = map(int, input().split())
arr = input()

# ランレングス圧縮
compressed = []
curr = ""
for x in arr:
    if curr != x:
        compressed.append(x)
        curr = x

# 境界の個数はランレングス圧縮後の文字数 - 1
boundary = len(compressed) - 1

# 2個ずつ圧縮可能
x = max(0, boundary - 2 * k)

print(n - 1 - x)
# Judge status: Wrong Answer
a,b= list(map(int,input().split()))
if 0 < a:
    print("Positive")
    exit()
elif 0<=b and a<=0:
    print("zero")
    exit()
elif b < 0:
    if abs(a-b)%2==0:
        print("Negative")
        exit()
    else:
        print("Positive")
        exit()
# Judge status: Wrong Answer
R = int(input())
2 * R * 3.14
# Judge status: Accepted
s = input()

flag = False
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        if s[:i] + s[j:] == "keyence":
            flag = True

if flag:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    ans = 10 * 10
    for i in range(min(A), max(A)+1):
        c = sum([(a-i)**2 for a in A])
        ans = min(ans, c)
    
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n, d = map(int, input().split())
count = 0
for i in range(n):
  a, b = map(int, input().split())
  k = a**2 + b**2
  if k > 0:
  	if (k)**(1/2) <= d:
  		count += 1
print(count)
# Judge status: Accepted
x = int(input())
if x == 7 or x == 5 or x == 3:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
from statistics import median_low, median_high

n = int(input())
a = [x-(i+1) for i, x in enumerate(list(map(int, input().split())))]


b1 = median_low(a)


b2 = median_high(a)
ans1 = 0
ans2 = 0

for aa in a:
    ans1 += abs(aa-b1)
    ans2 += abs(aa-b2)
print(min(ans1, ans2))
# Judge status: Wrong Answer
X,K,D = list(map(int,input().split()))

import numpy as np

if X > 0 and X > K*D:
    print(X-K*D)
elif X < 0 and X < K*D:
    print(X+K*D)
else:
    a = X // D
    b = a + 1
    if a % 2 != K % 2:
        print(np.abs(b*D - X))
    else:
        print(np.abs(X - a*D))
# Judge status: Accepted
N,A,B = map(int, input().split())

if A>B:
    print(0)
elif N==1:
    if A==B:
        print(1)
    else:
        print(0)
else:
    print((N-2)*(B-A)+1)
# Judge status: Accepted
a,b,c = map(int,input().split())
print(max(c-(a-b),0))
# Judge status: Wrong Answer
n=int(input())
ans = 1
for i in range(n):
    inp = int(input())
    tmp = ans * inp
    tmp2 =ans
    while (ans % inp != 0):
        if (inp % ans == 0):
            ans = inp
            break
        ans += tmp2
        print(ans)
        print(ans%inp)
print(ans)
# Judge status: Accepted
#!python3

LI = lambda: list(map(int, input().split()))

# input
X = int(input())


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


def main():
    g = gcd(X, 360)
    v = X // g
    ans = 360 * v // X
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
def pick(n):
  s = str(n)
  n_list = list(map(int, s))
  a = n % 10
  b = int(n_list[0])
  return str(b) + str(a)

ans = 0
N = int(input())
freq = [0] * 200000
for i in range(N):
  a = int(pick(i))
  freq[a] += 1		# 先頭がa，末尾がbとなるものの個数
for i in range(N):
  s = pick(i)
  b = int(s[1] + s[0])
  ans += freq[b]
  
print(ans-1)
# Judge status: Accepted
S = input()

if S == 'ABC':
    print('ARC')
if S == 'ARC':
    print('ABC')
# Judge status: Wrong Answer
def main():
  s = input()
  
  answer = 0
  
  while ("0" in s) and ("1" in s):
    answer += s.count("10")
    s = s.replace("10", "")
    answer += s.count("01")
    s = s.replace("01", "")
  
  print(answer)


if __name__ == "__main__":
  main()
# Judge status: Accepted
A=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
N=int(input())
S=list(input())
lenS=len(S)
for i in range(lenS):
    for j in range(len(A)):    
        if S[i]==A[j]:
            if j+N >=25:
                k=j-25+(N-1)
            else:
                k=j+N
    S[i]=A[k]
print(''.join(S))
# Judge status: Accepted
a,b = map(int, input().split())
print(0--(a+b)//2)
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[5]:


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


# In[6]:


ans = 0
for i in range(1,N+1):
    tmp = list(str(i))
    if sum(list(map(int, tmp))) >= A and sum(list(map(int, tmp))) <= B:
        ans += i
print(ans)


# In[ ]:
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    if p[i-1]>p[i] and p[i]>p[i+1] or p[i-1]<p[i] and p[i]<p[i+1]:
        ans += 1
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

res = True

for num in A:
    if num % 2 == 0 and num % 3 != 0 and num % 5 != 0:
        res = False
        break

print(['DENIED', 'APPROVED'][res])
# Judge status: Accepted
s = input()

a = s.find("A")
z = s.rfind("Z", a)

print(z - a + 1)
# Judge status: Wrong Answer
N = int(input())

fizzbuzzlist = range(N)
fizzbuzzlist = [i for i in fizzbuzzlist if i % 3 != 0]
fizzbuzzlist = [i for i in fizzbuzzlist if i % 5 != 0]

print(str(sum(fizzbuzzlist)))
# Judge status: Accepted
'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''
n = int(input())
a = [input() for i in range(n)]

ans = []

import collections
counter = collections.Counter(a)

max_h = max(counter.values())


for i in counter.items():
    #print(i)
    if i[1] == max_h:
        ans.append(i[0])
    else:
        pass

ans.sort()

[print(i) for i in ans]
# Judge status: Wrong Answer
import collections
N=int(input())
a=list(map(int,input().split()))
p=collections.Counter(a)
ans=0
for i in range(len(p)):
  if int(p.most_common()[i][0])<int(p.most_common()[i][1]):
    ans+=int(p.most_common()[i][1])-int(p.most_common()[i][0])
  elif int(p.most_common()[i][0])>int(p.most_common()[i][1]):
    ans+=min(int(p.most_common()[i][1]),int(p.most_common()[i][0])-int(p.most_common()[i][1]))
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = input()
t = input()

if (n == len(s) and (s == t)):
    print(n)
else:
    ind = [0]
    for i in range(1, len(s)):
        if s[-i] == t[:i]:
            ind.append(i)

    ind.reverse()
    for i in ind:
        if i == 0:
            print(2*n)
        else:
            res = s[0:-i] + t
            if len(res) >= n:
                print(len(res))
                break
# Judge status: Wrong Answer
#!/usr/bin/env python3
n, m, *a = map(int, open(0).read().split())
f = lambda j: j not in a

mod = 10**9+7

dp = [0] * -~n
dp[0] = 1
dp[1] = f(1)

for i in range(2, -~n):
    dp[i] += (dp[i - 1] + dp[i - 2]) * f(i) % mod

print(dp[n])
# Judge status: Accepted
N = int(input())
num = 0
index = 0
a_lst = []
for _ in range(N):
  a_lst.append(int(input()))
past_index = [0] * N
while True:
  num += 1
  index = a_lst[index]-1
  if index == 1:
    break
  elif past_index[index] == 1:
    num = -1
    break
  else:
    past_index[index] = 1
print(num)
# Judge status: Accepted
from decimal import Decimal, getcontext
getcontext().prec = 10000


def f(x):
    return Decimal(x).sqrt()


a, b, c = map(int, input().split())
eps = Decimal(10) ** (-1000)
if f(a) + f(b) + eps < f(c):
    ans = "Yes"
else:
    ans = "No"

print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
# 行
H=int(input())
# 列
W=int(input())

N=int(input())
num = 0
if H >= W:
    for i in range(W):
        if (i+1)*H >= N:
            num = i+1
            break
else:
    for j in range(H):
        if (j+1)*W >= N:
            num = j+1
            break
print(num)
# Judge status: Accepted
import sys
import collections
import bisect


def main():
    n, k = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    ab.sort(key=lambda x: x[0])
    cnt = 0
    for i in range(len(ab)):
        cnt += ab[i][1]
        if cnt >= k:
            print(ab[i][0])
            return


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()

ans = ["No"] * N
kaigai = 0
cnt = 0
for i in range(N):
    if S[i] == "a":
        if cnt < A + B:
            ans[i] = "Yes"
            cnt += 1

    elif S[i] == "b":
        if cnt < A+B and kaigai < B:
            ans[i] = "Yes"
            kaigai += 1
            cnt += 1

for i in ans:
    print(i)
# Judge status: Accepted
a,b = map(int, input().split())
count = 0

if a <= b:
    count = a
else:
    count = a-1

print(count)
# Judge status: Accepted
import math

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

cd = (C * D) // math.gcd(C, D)

pac, qac = divmod(A, C)
pad, qad = divmod(A, D)
pacd, qacd = divmod(A, cd)

pbc, qbc = divmod(B, C)
pbd, qbd = divmod(B, D)
pbcd, qbcd = divmod(B, cd)

pac = pac - 1 if qac == 0 else pac
pad = pad - 1 if qad != 0 else pad
pacd = pacd - 1 if qacd != 0 else pacd

ans = (pbc + pbd - pbcd) - (pac + pad - pacd)
print(B - A - ans + 1)
# Judge status: Accepted
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d=[0]
w=set([0])
x=0
for i in range(n):
    if a[x]-1 not in w:
        d.append(a[x]-1)
        w.add(a[x]-1)
        x=a[x]-1
    else:
        f=a[x]-1
        break

#print(d)
if k<len(d):
    print(d[k]+1)
else:
    x=k-len(d)
    y=d.index(f)
    z=len(d)-y
    #print(d,f,x,y,z)
    #exit()
    print(d[y+x%z]+1)
# Judge status: Accepted
N, M = map(int, input().split())
ship = [list(map(int, input().split())) for _ in range(M)]

s1 = [False] * N
sN = [False] * N

for i, s in enumerate(ship):
    if s[0] == 1:
        s1[s[1] - 1] = True

    if s[1] == N:
        sN[s[0] - 1] = True

ans = 'IMPOSSIBLE'
if any([p1 * pN for p1, pN in zip(s1, sN)]):
    ans = 'POSSIBLE'

print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
def p(n):
    a = set([1])
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a
s=p(a)
l=list(s)
for x in l:
  if b%x!=0:
    s.remove(x)
print(len(s))
# Judge status: Wrong Answer
n, l = map(int, input().split())
taste = [l+i for i in range(n)]
print(taste)
tmp = 9999
for t in taste:
  if abs(t) < tmp:
    tmp = t
res = sum(taste) - tmp
print(res)
# Judge status: Accepted
A, B, K = [int(x) for x in input().split(" ")]

if A >= K:
  print("{} {}".format(A-K, B))
elif A < K and A+B >= K:
  print("{} {}".format(0, int(A-K/2+B-K/2)))
else:
  print(0, 0)
# Judge status: Wrong Answer
A,B,C = list(map(int,input().split()))
if (A+B)>=C:
    print('Yes')
print('No')
# Judge status: Accepted
def main():
    A, B, K = map(int, input().split())
    if K <= A:
        print(A - K, B)
    elif K <= A + B:
        print(0, B - (K - A))
    else:
        print(0, 0)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
x,y=map(int,input().split())
if (x==y==1,3,5,7,8,10,12) or (x==y==4,6,9,11) or (x==y==2):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x,a,b = map(int, input().split())  
d = b-a

if (d <= 0):
    print('delicious ')
elif(d <= x):
    print('safe')
else:
    print('dangerous')
# Judge status: Wrong Answer
a,b=map(int,input().split())
s=input()
try:
  print("Yes" if s[:a]+"-"+s[a+1:]==s else "No")
except:
  print("No")
# Judge status: Wrong Answer
n=int(input())

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

s=0
for i in range(n-1):
    if a[i]>a[+1]:
        s+=a[i]-a[i+1]
    else:
        continue

print(s)
# Judge status: Wrong Answer
n, m = map(int, input().split())

listans = ["0"] * n
ans = 0

for i in range(m):
    s, c = map(str, input().split())
    if s == "1" and c == "0":
        ans = -1
    if listans[int(s)-1] != c:
        if listans[int(s)-1] == "0":
            listans[int(s)-1] = c
        else :
            ans = -1

if ans == 0:
    if listans[0] == "0":
        listans[0] = "1"
    ans = int("".join(listans))

print(ans)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
b = sorted(set(a))
c = Counter(a)
d = [0,0]
for i in b:
    if c[i]>1:
        d.append(i)
print(d[-1]*d[-2])
# Judge status: Accepted
N = int(input())

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


b=sum(B)

for i in range (N-1):
    if (A[i]+1==A[i+1]):
        b=b+C[A[i]-1]


print(b)
# Judge status: Accepted
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
maxA = 0
for s in set(S):
    maxA = max(maxA, S.count(s) - T.count(s))
print(maxA)
# Judge status: Accepted
n = int(input())
d = list(map(int, input().split()))
mod = 998244353

a = [0] * n
for d_ in d:
    a[d_] += 1

res = d[0] == 0 and a[0] == 1
pre = 1
for a_ in a:
    res = res * pre ** a_ % mod
    pre = a_

print(res)
# Judge status: Accepted
from sys import stdin


def run():
    n = int(stdin.readline().rstrip())
    data = [stdin.readline().rstrip() for _ in range(n)]

    print(len(set(data)))


if __name__ == '__main__':
    run()
# Judge status: Accepted
def sumDigits(i):
    s = 0
    while i > 0:
        s += (i % 10)
        i = int(i / 10)
    return s

N = int(input())

m = 9*6
for i in range(1, N):
    k = N - i
    m = min(m, sumDigits(i) + sumDigits(k))

print(m)
# Judge status: Accepted
string = input()
str_list = list(string)
display_string=""
for char in str_list:
    if char =="B":
        if len(display_string) != 0:
            display_string = display_string[:-1]
    else :
        display_string = display_string + char
print(display_string)
# Judge status: Accepted
n = int(input())
S = input()
L = S[: (n // 2)]
R = S[(n // 2) :]
if L == R:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
k = int(input())
if k%2 == 0:
    print(int((k/2)**2))
else:
    print(int(k/2 * (k+1)/2))
# Judge status: Wrong Answer
def md(x1, y1, x2, y2):
  return abs(x1 - x2) + abs(y1 - y2)

N = int(input())
Coordinates = [tuple(map(int, input().split())) for _  in range(N)]

maxd = 0
for i in range(N):
  for j in range(N):
    if i == j:
      continue
    else:
      d = md(Coordinates[i][0], Coordinates[i][1], Coordinates[j][1], Coordinates[j][1])
      if d > maxd:
        maxd = d
print(maxd)
# Judge status: Accepted
N = int(input())
robot = [input().split() for i in range(N)]

le = [[int(i[0])-int(i[1]), int(i[0])+int(i[1])] for i in robot]
le.sort(key = lambda x:x[1])

ans = 0
floor = -10**9-1
for i in range(N):
    if floor <= le[i][0]:
        ans += 1
        floor = le[i][1]

print(ans)
# Judge status: Accepted
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S - x - y <= K and S - x - y >= 0:
            ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))

mn = p[0]
ret = 0
for i in range(n):
    if mn >= p[i]:
        ret += 1
    mn = min(mn, p[i])
print(ret)
# Judge status: Accepted
D = int(input())
if D==25:
  print("Christmas")
if D==24:
  print("Christmas Eve")
if D==23:
  print("Christmas Eve Eve")
if D==22:
  print("Christmas Eve Eve Eve")
# Judge status: Accepted
S = list(input())
n = len(S)
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
ans = "Yes"

for i in range(1, n+1):
    if i % 2 == 0:
        if not S[i-1] in even:
            ans = "No"
            break
        else:
            continue
    else:
        if not S[i-1] in odd:
            ans = "No"
            break
        else:
            continue

print(ans)
# Judge status: Accepted
from collections import Counter

S = input()
T = input()

alps_counter_s = Counter(S).most_common()
alps_counter_t = Counter(T).most_common()

for s, t in zip(alps_counter_s, alps_counter_t):
    if s[1] != t[1]:
        print("No")
        break
else:
    print("Yes")
# Judge status: Accepted

def main():

    N = int(input())
    money = 0

    while N > money:
        money += 1000

    print(money - N)



if __name__ == '__main__':
    main()
# Judge status: Accepted
N,M = map(int,input().split())

print((N+M)%24)
# Judge status: Accepted
n = int(input())
ar = []
mi = 0
mx = 0
count = 1
for i in range(n):
    a,b = map(int,input().split(" "))
    br = [a+b,a-b]
    ar.append(br)
ar.sort()
for i,r in enumerate(ar):
    if i == 0:
        mx = r[0]
    else:
        if mx <= r[1]:
            count += 1
            mx = r[0]
print(count)
# Judge status: Accepted
import bisect
N,Q=map(int,input().split())
S=input()

AC=[]

for i,s in enumerate(S):
    if i>=1:
        if s=="C" and S[i-1]=="A":
            AC.append(i-1)
#print(AC)
for i in range(Q):
    l,r=map(int,input().split())
    left=bisect.bisect_left(AC,l-1)
    right=bisect.bisect_right(AC,r-2)
    #print("----")
    print(right-left)
# Judge status: Wrong Answer
def min_cost(h, n, k):
    dp = [10**6 for i in range(n)]
    dp[0] = 0
    for i in range(1, n):
        for k in range(1, k + 1):
            if (i - k) >= 0:
                dp[i] = min(abs(h[i] - h[i - k]) + dp[i - k], dp[i])


    return dp[n - 1] 

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
print(min_cost(h, n, k))
# Judge status: Accepted
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    sumLs = sum(num_list)

    minCount = 10**9

    left = 0
    right = 0

    for i in range(n):
        left += num_list[i]
        right = sumLs - left
        minCount = min(abs(left-right),minCount)

    print(minCount)

if __name__ == '__main__':
    main()
# Judge status: Accepted
def main(n,a,b):
    res = 0
    for i in range(1, n+1):
        val = sub(i)
        if a <= val and val <= b:
            res += i
    return res

def sub(val):
    res = 0
    x = val
    while x > 0:
        x, j = divmod(x,10)
        res += j
    return res

n,a,b = map(int, input().split())
print(main(n,a,b))
# Judge status: Accepted
n=int(input())

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

t.sort()

memo = []
check = 1
for i in range(n-1):
    if t[i] == t[i+1] and i == n-2:
        check += 1
        memo.extend([t[i]]*(check//2))
    elif t[i] == t[i+1]:
        check += 1
    elif t[i] != t[i+1] and check>1:
        memo.extend([t[i]]*(check//2))
        check = 1

memo.sort(reverse=True)

if len(memo)>1:
    print(memo[0]*memo[1])
else:
    print(0)
# Judge status: Accepted
N = list(map(int, input()))
N.insert(0, 0)
count = 0
for i in range(len(N)-1, -1, -1):
    if N[i] <= 4 or (N[i] == 5 and N[i-1] <= 4):
        count += N[i]
    else:
        count += 10 - N[i]
        N[i-1] = N[i-1] + 1
print(count)
# Judge status: Wrong Answer
N = int(input())
i = 2
a = 0
while i <= N:
    a += N // i
    i *= 2
i = 2*5
b = 0
while i <= N:
    b += N // i
    i *= 5
print(min(a,b))
# Judge status: Wrong Answer
#ライブラリの読み込み
import math

#入力値の格納
k,x = map(int,input().split())

#判定
if k * 500 >= x:
    text = "yes"
else:
    text = "No"

#表示
print(text)
# Judge status: Wrong Answer
n,m=map(int,input().split())
x=n*(n-1)/2+m*(m-1)/2
print(x)