peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
m, d= map(int, input().split())
if m <= d:
  print(m)
else:
  print(m - 1)
# Judge status: Accepted
s = int(input())
S = set()
cnt = 1
while not s in S:
    S.add(s)
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    cnt += 1
print(cnt)
# Judge status: Accepted
n,m=map(int,input().split())
mylist=[n]*m
for i in range(n):
    ans=list(map(int,input().split()))
    for j in range(1,ans[0]+1):
        mylist[ans[j]-1]-=1
print(mylist.count(0))
# Judge status: Wrong Answer
S = input()
S_inv = S[::-1]

out = 0
for i in range(len(S)):
  if S[i] != S_inv[i]:
    out = out + 1

print(out)
# Judge status: Accepted
x = int(input())
if x >=30:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N=int(input())
W=[input() for i in range(N)]
if N!=len(set(W)):
  print("No")
  exit()
for i in range(N-1):
  if W[i][-1]!=W[i+1][0]:
    print("No")
    exit()
print("Yes")
# Judge status: Wrong Answer
def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, mod-3, mod)

n, a, b = map(int,input().split())

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))
# Judge status: Wrong Answer
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    score=i
    cnt=0
    while k>=score>=0:
        score*=2
        cnt+=1
    ans+=1/n*0.5**cnt
print(ans)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
if C < B:
	if C > A:
		print('YES')
else:
	print('NO')
# Judge status: Wrong Answer
x, y, z = map(int, input().split())
print((x + z) // (y + z))
# Judge status: Accepted
N, Q = map(int, input().split())
S = input()
cnt = [0]*N
for i in range(1,N):
    cnt[i] = cnt[i-1]
    if S[i-1] == 'A' and S[i] == 'C':
        cnt[i] += 1
for i in range(Q):
    l, r = map(int, input().split())
    print(cnt[r-1]-cnt[l-1])
# Judge status: Accepted
s = input()
l = len(s)//2
if 'hi'*l == s:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
c = Counter(A)

over4 = []
over2 = []

for k, v in c.items():
    if v >= 4:
        over4.append(k)
    elif v >= 2:
        over2.append(k)

over4.sort(reverse=True)
over2.sort(reverse=True)

s1, s2, s3 = 0, 0, 0
if len(over4) > 0:
    s1 = over4[0]**2
if len(over2) >= 2:
    s2 = over2[0]*over2[1]
if len(over4) > 0 and len(over2) > 0:
    s3 = over4[0]*over2[0]

print(max(s1, s2, s3))
# Judge status: Accepted
s=input()
n=len(s)+1
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(1,n):
  b[i]=(b[i-1]+1 if s[i-1]=='<' else 0)
for i in range(n-2,-1,-1):
  c[i]=(c[i+1]+1 if s[i]=='>' else 0)
for i in range(n):
  a[i]=max(b[i],c[i])
print(sum(a))
# Judge status: Wrong Answer
i = list(map(int, input().split()))

if i[0]<=i[2] and i[1]>=i[2]:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
import numpy as np
N,M=map(int, input().split())  
sc=np.array([list(map(int,list(input().split()))) for i in range(M)])

ans = np.zeros(N)
checked=False
for i in range(M):
  s=sc[i][0]
  c=sc[i][1]
  if N!=1 and s==1 and c==0:
    checked=True
    break
  for j in range(i):
    if s==sc[j][0] and c!=sc[j][1]:
      checked=True
      break
  ans[s-1] = c

if checked:
  print(-1)
else:
  if N!=1 and ans[0]==0:
    ans[0]=1
  res = ''
  for i in ans:
    res += str(int(i))
  print(int(res))
# Judge status: Accepted
from sys import stdin
X = int(stdin.readline().rstrip())
print(10-X//200)
# Judge status: Wrong Answer
import math
from fractions import gcd

a, b = map(int, input().split())
cd = set()
ans = 0

g = gcd(a, b)

if g == 1:
    cd.add(1)
else:
    for i in range(1, g):
        if a % i == 0 and b % i == 0:
            cd.add(i)

for s in cd:
    if s == 1:
        ans += 1
    else:
        for t in range(2, int(math.sqrt(s)) + 1):
            if s % t == 0:
                break
        else:
            ans += 1

print(ans)
# Judge status: Accepted
N,K = map(int , input().split())
A = list(map(int, input().split()))
for i in range(N-K):
    if (A[i]<A[-(N-K)+i]):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
N,X,T = map(int,input().split())

if N%X == 0:
    print(N//X*T)
else:
    print((N//X+1)*T)
# Judge status: Accepted
import sys 
input = lambda:sys.stdin.readline().strip()
a = int(input())
print(a+a**2+a**3)
# Judge status: Accepted
#ABC122-B
s = input()
atgc = set(['A','T','G','C'])
cnt = 0
acgt_len = []
for i in range(len(s)):
    if s[i] in atgc:
        cnt += 1
        
    else:
        acgt_len.append(cnt)
        cnt = 0
        
acgt_len.append(cnt)

print(max(acgt_len))
# Judge status: Wrong Answer
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    a, b, c = Input()
    print(b * a * 1/2)

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

if sum(a) >= 22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
n=int(input())
k=int(n**0.5)+1
num=[0 for i in range(n+1)]
for x in range(1,k):
  for y in range(1,k):
    for z in range(1,k): 
      w=x**2+y**2+z**2+x*y+y*z+z*x
      if w<=n:
        num[w]+=1
for i in range(1,n+1):
  print(num[i])
# Judge status: Accepted
def main():
    a = list(map(int, input().split()))
    if len(set(a)) == 2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
def gcd(a,b):
	while(b):
		a,b = b,a%b
	return a
def main():
	k = int(input())
	ans=0
	for a in range(1,k+1):
		for b in range(1,k+1):
			for c in range(1,k+1):
				ans+=gcd(a,gcd(b,c))

	print(ans)
if __name__ == '__main__':
	main()
# Judge status: Accepted
N = int(input())
S = input()

countE = [0]*(N+1)
countW = [0]*(N+1)

for i in range(N):
    countW[i + 1] = countW[i]
    if S[i] == 'W':
        countW[i+1] += 1

for i in range(1, N):
    countE[N-i-1] = countE[N-i]
    if S[N-i] == 'E':
        countE[N-i - 1] += 1

minx = N+1
for i in range(N):
    newv = countW[i] + countE[i]
    if minx > newv:
        minx = newv

print(minx)
# Judge status: Accepted
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

xs = [A, B, C, D, E]
min_value = min(xs)
min_index = xs.index(min_value)

print(4 + (N + min_value - 1) // min_value)
# Judge status: Wrong Answer
n,m=map(int,input().split())
if n==1 or m==1:
    print(max(n,m)-2)
else:
    print(n*m-(2*n+2*m-4))
# Judge status: Wrong Answer
n= int(input())
arr = list(map(int,input().split()))
c=0
for i in range(1,n,2):
    if (arr[i])%2==1:
        c+=1
print(c)
# Judge status: Accepted
print('Yes' if len(set(input())) == 3 else 'No')
# Judge status: Accepted
x=int(input())
for i in range(9):
  if 400+200*i <= x and x <= 599+200*i:
      print(8-i)
  else:
    pass
# Judge status: Wrong Answer
S = input().strip()
T = input().strip()
ans = "UNRESTORABLE"
for i in range(len(S)-len(T), -1, -1):
    ok = True
    for j in range(len(T)):
        if not (S[i+j] == '?' or S[i+j] == T[j]):
            ok = False

    if ok:
        a = S[:i]+T
        a = a.replace("?", "a")
        if ans == "UNRESTORABLE" or a < ans:
            ans = a
print(ans)
# Judge status: Wrong Answer
x = int(input())
t = x // 11
if x % 11 <= 6:
    print(t*2 + 1)
else:
    print(t * 2 + 2)
# Judge status: Accepted
#6484898
from bisect import bisect
N= int(input())
A = []
for i in range(N):
    t = int(input())
    A.append(t)

D = [1]*(N+1)
D[0] = -10**10
for a in A:
    idx = bisect(D, -a)
    D[idx] = min(D[idx], -a)
print(bisect(D, 0)-1)
# Judge status: Wrong Answer
import sys

s = input()
t = input()

for i in range(len(s)):
  if s[i] != t[i]:
    print('false')
    sys.exit()
else:
  print('true')
# Judge status: Accepted
s=list(input())
s[0],s[1],s[2],s[3]='2','0','1','8'
print(''.join(s))
# Judge status: Accepted
from collections import Counter


N = int(input())
A = map(int, input().split())
edge = Counter(A)

cand = [a for a in edge.keys() if edge[a] >= 2]
cand.sort(reverse=True)

e1 = e2 = 0
if len(cand) >= 1:
    if edge[cand[0]] >= 4:
        e1 = e2 = cand[0]
    elif len(cand) > 1:
        e1 = cand[0]
        e2 = cand[1]

print(e1 * e2)
# Judge status: Accepted

def main():
    N = int(input())
    dict = {}

    for _ in range(N):
        word = input()
        if word in dict:
            dict[word] += 1
        else:
            dict[word] = 0

    m = max(dict.values())
    dict = sorted(dict.items(), key=lambda x: x[0])

    for d in dict:
        if d[1] == m:
            print(d[0])
    return 0


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
#ABC081

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

s = sum(a)
s // (2 ** n)
c = True
count = 0
while c:
    
    a = [a[i] // 2 for i in range(len(a))]
    count += 1
    for i in range(n):
        if a[i] % 2 != 0:
            c = False
print(count)
# Judge status: Accepted
N = input()
if N[1:] == "9" * (len(N) - 1):
    print(int(N[0]) + 9 * (len(N) - 1))
else:
    print((int(N[0]) - 1) + 9 * (len(N) - 1))
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>b or (a==1 and b==13):
    print("Alice")
elif a<b or (a==13 and b==1):
    print("Bob")
else:
    print("Drew")
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

if (a//d) < (c//b):
    print("No")
elif ((a//d) == (c//b)) and (c%b != 0) and (a%d == 0):
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
N = int(input())
X = list(map(int, input().split()))
import math
av = math.ceil(sum(X)/N)
total = 0

for i in X:
    total += ((i-av)**2)

print(total)
# Judge status: Accepted
N = int(input())
txy = [map(int, input().split()) for _ in range(N)]

for t, x, y in txy:
    dist = x + y
    if t < dist or t % 2 != dist % 2:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
# A - Between Two Integers
a,b,c=list(map(int,input().split()))
if c>=a and c<=b:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
def solve():
    A, B, K = map(int, input().split())
    ans = []
    if A + B == K:
        ans = [0, 0]
    elif A + B < K:
        ans = [0, 0]
    elif K <= A:
        ans = [A-K, B]
    elif A < K <= B:
        ans = [0, B+A-K]
    print(*ans)

# print(solve())
solve()
# Judge status: Wrong Answer
S = input()
cnt_0 = 0
cnt_1 = 0
for i in S:
    if i == "0":
        cnt_0 += 1
    else:
        cnt_1 +=1
print(min(cnt_0,cnt_1))
# Judge status: Accepted
a, b = map(int, input().split())
# = list(map(int, input().split()))
# = [list(map(int, input().split())) for i in range(N)]

if a <0 and b>0:
    print("Zero")

elif a==0 or b==0:
    print("Zero")

elif a>0:
    print("Positive")

elif a<0 and b<0:
    if (a-b)%2==0:
        print("Negative")
    else:
        print("Positive")
# Judge status: Accepted
n,m = map(int,input().split())
a = [[str(i) for i in input()]for _ in range(n)]
b = [[str(i) for i in input()]for _ in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    c =0
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l] == b[k][l]:
          c +=1
          
          
    
    if c == m**2:
      print("Yes")
      exit()
      
      
      
print("No")
# Judge status: Wrong Answer
import sys
input = sys.stdin.buffer.readline
import numpy as np

D = int(input())
c = np.array(input().split(), dtype=np.int32)
s = np.array([input().split() for _ in range(D)], dtype=np.int32)
last = np.zeros(26, dtype=np.int32)


ans = []
point = 0
for i in range(D):
    down = (i+1-last)*c
    loss = down * 3 + s[i,:]
    idx = np.argmax(loss)
    ans.append(idx+1)
    point += s[i, idx] - down.sum()
    last[idx] = i+1
    print(down)
    
for i in range(D):
    print(ans[i])
# Judge status: Accepted
s = input()
t = input()
if len(s)+1 == len(t) and s == t[:len(t)-1]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N, M = map(int, input().split())
if N > M:
    tmp = N
    N = M
    M = tmp

# N <= M としても一般性を失わない
if N == 1:
    if M == 1:
        print(1)
    elif M == 2:
        print(0)
    else:
        print(M-2)
elif N == 2:
    print(0)
else:
    print((N-2)*(M-2))
# Judge status: Accepted
n = int(input())

cnt = 0
for i in range(1,n+1):
    cnt += i
    if cnt >= n:
        idx = i
        break


sum = 0
for i in range(1,idx+1)[::-1]:
    if sum+i < n:
       print(i)
       sum += i
    
    else:
        print(n-sum)
        break
# Judge status: Accepted
def main():
    x,y = map(int,input().split())
    ans = 10**10
    if x<=y:
        ans = min(ans,y-x)
    if -x<=y:
        ans = min(ans,1+y-(-x))
    if x<=-y:
        ans = min(ans,-y-x+1)
    if -x<=-y:
        ans = min(ans,-y-(-x)+2)
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N=int(input())
print((-(-N//1000)*1000)-N)
# Judge status: Wrong Answer
import math
N, M = map(int, input().split())
a = list(map(int, input().split()))

a = list(map(lambda x: x / 2, a))
a.sort()

bound = int(M / a[0])
base = 0
for factor in range(bound):
    for i in range(1, N):
        if (a[0] * factor) % a[i]:
            break
        elif i == N-1:
            base = a[0] * factor
            break

    if base != 0:
        break

if base != 0:
    print(math.ceil((M // base) / 2))
else:
    print(0)
# Judge status: Accepted
from bisect import *
N, L = map(int, input().split())
A = list(range(L,L+N))
res = sum(A)
print(res - A[min(bisect_left(A,0),len(A)-1)])
# Judge status: Accepted
n = int(input())
if n%9==0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, D = map(int, input().split())

print((N+D*2)//(D*2+1))
# Judge status: Wrong Answer
k,x = map(int,input().split())
res = [i for i in range(x-k+1,x+k)]
print(res)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

cnt=[0]*(n+1)
s=0

for x in a:
    cnt[x]+=1

for i in range(1,n+1):
    if cnt[i]>=2:
        s+=cnt[i]*(cnt[i]-1)//2

for k in range(1,n+1):
    if cnt[a[k-1]]>=2:
        print(s-cnt[a[k-1]]+1)
    else:
        print(s)
# Judge status: Accepted
A,B,C,X,Y = map(int,input().split())
moneys = []

for i in range(0,2*max(X,Y)+1,2):
  if X-i//2 >= 0 and Y-i//2 >= 0:
    moneys.append((X-i//2)*A + (Y-i//2)*B + C*i)
  elif X-i//2 >= 0 and Y-i//2 < 0:
    moneys.append((X-i//2)*A + C*i)
  elif X-i//2 < 0 and Y-i//2 >= 0:
    moneys.append((Y-i//2)*B + C*i)
  else:
    moneys.append(C*i)
    
print(min(moneys))
# Judge status: Wrong Answer
t=input()
s=raw_input()
if t%2!=0:
  print "No"
else:
  if s[0:t/2]==s[t/2+1:t-1]:
    print "No"
  else:
    print "Yes"
# Judge status: Wrong Answer
a,b,c,x,y = map(int,input().split())
c *= 2
ans = 10 ** 8
for i in range(max(x,y)):
    p = 0
    p += c * i
    p += a * (max(0,x - i))
    p += b * (max(0,y - i))
    ans = min(ans,p)
print(ans)
# Judge status: Accepted
S = input()
T = input()
length = len(S)
flg = 1
dic = {}
for i in range(length):
    data = S[i]
    if S[i] not in dic:  dic[S[i]] = T[i]
    else:
        if dic[S[i]] != T[i]:  flg = 0

dic = {}
for i in range(length):
    data = T[i]
    if T[i] not in dic:  
        dic[T[i]] = S[i]
    else:
        if dic[T[i]] != S[i]:  flg = 0
                
if flg:  print("Yes")
else:  print("No")
# Judge status: Accepted
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


S = input()
print('Yes' if 'a' in S and 'b' in S and 'c' in S else 'No')
# Judge status: Wrong Answer
import math

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

p_sort = sorted(p)
q_sort = sorted(q)

p_number = 0
q_number = 0

k = 0
for i in p:
  k += 1
  i_index = p_sort.index(i)
  p_number += i_index * math.factorial(n-k)
  p.remove(i)
  p_sort.remove(i)

k = 0
for i in q:
  k += 1
  i_index = q_sort.index(i)
  q_number += i_index * math.factorial(n-k)
  q.remove(i)
  q_sort.remove(i)

answer = abs(p_number - q_number)
print(answer)
# Judge status: Wrong Answer
N=int(input())
MOD=10**9+7
MAX=N+1
def powermod(base,p):
  powls=[0 for i in range(MAX)]
  powls[0]=1
  if powls[p]!=0:
    return powls[p]
  elif p%2==0:
    return (powermod(base,p//2)**2)%MOD
  else:
    return (powermod(base,p-1)*base)%MOD

print(powermod(10,N)-2*powermod(9,N)+powermod(8,N))
# Judge status: Accepted
a,b,k = map(int,input().split())

if k <= a:
    a = a - k
    print("{} {}".format(a,b))
else:
    if k >= a + b:
        print("0 0")
    else:
        print("0 {}".format(b - (k - a)))
# Judge status: Wrong Answer
N, T = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(N)]
ct = sorted(ct, key=lambda x:x[1])
mx = float('inf')
for c, t in ct:
    if t <= T:
        mx = min(mx, c)
    else:
        if mx != float('inf'):
            print(mx)
            exit()
print('TLE')
# Judge status: Accepted
n=int(input())
l=[input() for i in range(n)]
l.sort()
ll=list(set(l))
ll.sort()
m=len(ll)
ans=[0]*m
count=0
j=0
for i in range(len(l)-1):
  if l[i]==l[i+1]:
    count+=1
    if i+1==n-1:
      ans[j]+=count
  else:
    ans[j]+=count
    count=0
    j+=1
g=max(ans)
for i in range(m):
  if ans[i]==g:
    print(ll[i])
# Judge status: Accepted
s=int(input())
a=[s]
check=0
for i in range(1000000):
    n=a[i]
    if n%2==0:
        num=n//2
        if num in a:
            check=i+2
            break
        a.append(num)
    else:
        num=3*n+1
        if num in a:
            check=i+2
            break
        a.append(num)
print(check)
#print(*a)
# Judge status: Accepted
a = list(map(int,input().split()))
count=0
for i in a:
    count+=i
if count < 22:
    print("win")
else:
    print("bust")
# Judge status: Wrong Answer
a, b = input().split()
t = int(a + b)
for i in range(1,10 ** 2 + 2):
    if t == (i * i):
        print('Yes')
        exit(0)
print('No')
# Judge status: Wrong Answer
K,S=map(int,input().split())

# if S%3==0:
#     x=int(S/3)
# elif S%2==0:
#     x=int(S/2)
# else:
#     x=int(S)

ans=0

for i in range(0,K+1):
    for j in range(0,K+1):
        for k in range(0,K+1):
            print(i,j,k)
            if i+j+k==S:
                ans+=1

print(ans)
# Judge status: Accepted
N = int(input())
A = [int(input()) for i in range(N)]

import bisect

bilist = [A[0]]
ans = 0

for a in A[1:]:
    index = bisect.bisect_left(bilist,a)
    if index == 0:
        bisect.insort_left(bilist,a)
    else:
        bilist[index-1] = a


print(len(bilist))
# Judge status: Accepted
N, K = [int(i) for i in input().split(" ")]
D = input().split(" ")

for i in range(N, 1000000):
    if len(list(set(D) & set(str(i)))) == 0:
        print(i)
        break
# Judge status: Wrong Answer
N,K=map(int,input().split())
ans=1
a=K

while N>a:
    ans+=1
    a=a*K
print(ans)
# Judge status: Wrong Answer
number = int(input())
power = 1;

for i in range(number):
  power = power * i
  
print(power)
# Judge status: Wrong Answer
a,b = [int(x) for x in input().split()]
amax = (a+1)*12.5
amin = a*12.5
bmax = int((b+1)*10)
bmin = int(b*10)
hantei = bmin
if amax <= bmin:
  hantei = str(-1)
elif bmax <= amin:
  hantei = str(-1)
elif bmin < amin:
  hantei = round(amin)
print(hantei)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
s=0
for i in range(n):
    s=s^l[i]
k=s
y=0
for i in range(n):
   y=k^l[i]
   print(y,end=" ")
# Judge status: Wrong Answer
N = int(input())
A = int(input())
if (N-A)%500 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
X = int(input())

if X <= 400 and X <= 599:
    print('8')
elif 600 <= X and X <= 799:
    print('7')
elif 800 <= X and X <= 999:
    print('6')
elif 1000 <= X and X <= 1199:
    print('5')
elif 1200 <= X and X <= 1399:
    print('4')
elif 1400 <= X and X <= 1599:
    print('3')
elif 1600 <= X and X <= 1799:
    print('2')
elif 1800 <= X and X <= 1999:
    print('1')
else:
    pass
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a <= 0 <= b:
    print("Zero")
elif a < 0 and b < 0:
    subs = b - a + 1
    if subs % 2 == 1:
        print("Negative")
else:
    print("Positive")
# Judge status: Accepted
x = int(input())
# = list(map(int, input().split()))
# = map(int, input().split())
ans = 10 - x // 200
print(ans)
# Judge status: Wrong Answer
n,k = map(int,input().split())
ans = 1
while n>k:
    n = n/k
    ans+=1
print(ans)
# Judge status: Accepted
from collections import Counter

n = int(input())
s = input()
mod = 10 ** 9 + 7
cnt = 1
for i in Counter(list(s)).values():
    cnt *= (i + 1)
print((cnt - 1) % mod)
# Judge status: Wrong Answer
"""
- N players, K points each player has, Q correct answers
- Substruct Q from K and add score to each players
"""

N,K,Q = map(int,input().split())
A = (int(x) for x in open(0).read().split())

score = [K-Q] * (N+1) 
for x in A:
    score[x] += 1

ans = '\n'.join('No' if x <= 0 else 'Yes' for x in score[1:])
print(ans)
# Judge status: Wrong Answer
S = str(input())

N = len(S) + 1

ans = [0] * N


for i in range(N):
    k = 0
    right = 0
    while(i + k < N-1 and S[i+k] == '>'):
        right += 1
        k += 1

    j = 0
    left = 0
    while (N-1 > i - j - 1 > 0 and S[i - j - 1] == '<'):
        left += 1
        j += 1


    ans[i] = max(right, left)

#print(ans)
print(sum(ans))
# Judge status: Wrong Answer
c = str(input())
vowels = ['a','e','i','o','u']

if c in vowels:
    answer = "vowei"
else:
    answer = "consonant"

print(answer)
# Judge status: Accepted
S = input()
cnt_a = 0
cnt_b = 0
cnt_c = 0
for s in S:
    if s == 'a':
        cnt_a += 1
    elif s == 'b':
        cnt_b += 1
    else:
        cnt_c += 1
if abs(cnt_a - cnt_b) <= 1 and abs(cnt_b - cnt_c) <= 1 and abs(cnt_c - cnt_a) <= 1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N = 1000
Y = 1234000
##N,Y = map(int,input().split())

ans = -1,-1,-1
for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y:
            ans = x,y,z
            break
        else:
            break

print(*ans)
# Judge status: Accepted
a,b,x = map(int,input().split())
print('YES' if a <= x <= a+b else 'NO')
# Judge status: Accepted
from math import ceil
n = int(input())
cc = [0]*(n-1)
ss = [0]*(n-1)
ff = [0]*(n-1)
ans = [0]*n

for i in range(n-1):
    c,s,f = map(int,input().split())
    cc[i] = c
    ss[i] = s
    ff[i] = f   

for i in range(n-1):
    for j in range(i,n-1):
        x = max(0,ceil((ans[i]-ss[j])/ff[j]))
        ans[i] = ss[j] + x*ff[j] + cc[j]

for i in range(n):
    print(ans[i])
# Judge status: Accepted
n,p=map(int,input().split())
a=list(map(lambda x:int(x)%2,input().split()))
a0=a.count(0)
a1=a.count(1)
base=2**a0

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if p==1:
  ans=0
  for i in range((a1+1)//2):
    b=combinations_count(a1, 2*i+1)
    ans+=base*b
  print(ans)
else:
  ans=0
  for i in range(a1//2+1):
    b=combinations_count(a1, 2*i)
    ans+=base*b
  print(ans)
# Judge status: Accepted
n=int(input())
from collections import Counter as co
var=co(list(map(int,input().split())))
ans=0
for k in var:
  p=var[k]
  if k-1 in var:p+=var[k-1]
  if k+1 in var:p+=var[k+1]
  
  ans=max(ans,p)
print(ans)
# Judge status: Accepted
# ABC 131: B – Bite Eating
N, L = [int(s) for s in input().split()]
tastes = [L + i - 1 for i in range(1, N + 1)]

index = 0
taste = 500

for i in range(N):
    if abs(tastes[i]) < taste:
        index = i
        taste = abs(tastes[i])

tastes.pop(index)
print(sum(tastes))
# Judge status: Accepted
n = int(input())
print((n // 2) * ((n + 1)// 2))
# Judge status: Accepted
a,b,c,d = map(int,input().split())
if a >= d or b <= c:
  print(0)
elif a <= c:
  print(min(b,d)-c)
else:
  print(min(b,d)-a)
# Judge status: Accepted
n = int(input())
arm = []
for _ in range(n):
    x, l = map(int,input().split())
    arm.append([x-l, x+l])
arm.sort(key=lambda x: x[1])
cnt = 0
pr = -float('inf')
for a in arm:
    if pr <= a[0]:
        cnt += 1
        pr = a[1]
print(cnt)
# Judge status: Accepted
n,k = map(int, input().split())
s = list(input())
s[k-1] = s[k-1].lower()
print(*s, sep='')