Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
#階乗計算
from math import factorial
n,m=map(int,input().split())
nf=factorial(n)
mf=factorial(m)
mnf=factorial((m-n))
#n=mの時
def ko1(x):
  kosuu1=0
  for i in range(x+1):
    kf=factorial(i)
    kosuu1+=int((nf/kf)*((-1)**i))
  kosuu1*=nf
  return kosuu1
#n<mの時
def ko2(x,y):
  kosuu2=0
  for i in range(x+1):
    kf=factorial(i)
    mi=factorial((y-i))
    ni=factorial((x-i))
    kosuu2+=int((((-1)**i)*mi*nf)/(ni*mnf*kf))
  kosuu2*=int(mf/mnf)
  return kosuu2
if n==m:
  kosuu=int(ko1(n)/(10**9+1))
else:
  kosuu=int((ko2(n,m))%(10**9+1))
print(kosuu)

### FIXED CODE ###

# -*- coding: utf-8 -*-
#nCをp(=10**9+7)で割ったときのあまり(モジュラ逆数)
def cmb(n,r,p):
  if r<0 or n<r:
    return 0
  r=min(r,n-r)
  return facto[n]*factoinv[r]*factoinv[n-r]%p
p=10**9+7
n,m=map(int,input().split())
#0,1の時の値をいれたn!のリスト(modp)
facto=[1,1]
#0,1の時の値をいれたn!の逆元のリスト(modp)
factoinv=[1,1]
#0,1の場合を入れたn!の逆元も求めるために使うnの逆元のリスト(modp)
inv=[0,1]
#2からスタート
for i in range(2,m+1):
  facto.append((facto[-1]*i)%p)
  inv.append((-inv[p%i]*(p//i))%p)
  factoinv.append((factoinv[-1]*inv[-1])%p)
if n==m:
  kosuub=0
  for i in range(n+1):
    kosuub+=(facto[(n-i)]*cmb(n,i,p)*((-1)**i))%p
  kosuu=(kosuub*facto[(n)])%p
  print(kosuu)
else:
  kosuub=0
  for i in range(n+1):
    kosuub+=(cmb((m-i),(n-i),p)*facto[(n-i)]*cmb(n,i,p)*((-1)**i))%p
  kosuu=(kosuub*cmb(m,n,p)*facto[n])%p
  print(kosuu)
a = int(input())
b = int(input())

if(a<1 or a>9):
    print(-1)
elif(b<1 or b>9):
    print(-1)
else:
    print(a*b)
    

### FIXED CODE ###

s = input().split()
a = int(s[0])
b = int(s[1])

if(a<1 or a>9):
    print(-1)
elif(b<1 or b>9):
    print(-1)
else:
    print(a*b)
n=int(input())
a=sorted[int(input()) for _ in range(n)]
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
if a[n-2]==a[n-1]:
  ans+=k%2
print(ans)

### FIXED CODE ###

n=int(input())
a=sorted([int(input()) for _ in range(n)])
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
ans+=k%2
print(ans)
import math
import numpy as np

L = int(input())
#print(L)

a0 = math.floor(L/2)
#print(a0)

cand = []

if a0==1:
  b0 = -2*a0 + L
  cand.append(a0*b0*a0)
else:
  x = np.arange(0.1, a0, 0.1)
  for i in x:
    b0 = -2*i + L
    cand.append(i*b0*i)

cand_np = np.array(cand)
print(cand_np.max())


### FIXED CODE ###

import math
import numpy as np

L = int(input())
a0 = L/3

print(a0*a0*a0)
l=list().split()
print(1+l.index("0"))

### FIXED CODE ###

l=input().split()
print(1+l.index("0"))
k, x = map(int, input().split())

start = x - k + 1
last = x + k - 1

result = []
result.append(start)

for i in range(1, last - start + 1):
    print(i)
    result.append(start + i)
for i in result:
    if i == start:
	output = str(i)
    else:
        output = output + " " + str(i)
print(output)

### FIXED CODE ###

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

start = x - k + 1
last = x + k - 1

result = []
result.append(start)

for i in range(1, last - start + 1):
    result.append(start + i)
for i in result:
    if i == start:
	    output = str(i)
    else:
        output = output + " " + str(i)

print(output)
from sys import stdin


class Rec_memo:
    def __init__(self, N, h_arr):
        self.dp = [float('inf')] * (N+2)
        self.h_arr = h_arr

    def rec(self, i):
        if self.dp[i] != float('inf'):
            return self.dp[i]
        elif i == 0:
            return 0
        else:
            res = float('inf')
            res = min(res,self.rec(i-1)+abs(self.h_arr[i]-self.h_arr[i-1]))
            if i>1:
                res = min(res,self.rec(i-2)+abs(self.h_arr[i]-self.h_arr[i-2]))
            self.dp[i] = res
            return res


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = [0] * (N+2)
    h_arr[0:N] = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    # dp[i]:=カエルが足場iへと移動するのに必要な最小コスト
    dp = [float('inf')] * (N+2)  # 最小化問題
    dp[0] = 0                    # 初期条件
    
    # 貰うDP
    #for i in range(0,N):
    #    dp[i] = min(dp[i],dp[i-1]+abs(h_arr[i]-h_arr[i-1]))
    #    if i > 1:
    #        dp[i] = min(dp[i],dp[i-2]+abs(h_arr[i]-h_arr[i-2]))
    #cnt = dp[N-1]

    # 配るDP
    #for i in range(0,N):
    #    dp[i+1] = min(dp[i+1],dp[i]+abs(h_arr[i]-h_arr[i+1]))
    #    dp[i+2] = min(dp[i+2],dp[i]+abs(h_arr[i]-h_arr[i+2]))
    #cnt = dp[N-1]

    # メモ化再帰
    memo = Rec_memo(N,h_arr)
    cnt = memo.rec(N-1)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


### FIXED CODE ###

from sys import stdin


# 最小化問題
def chmin(a,b):
    if a > b: return b
    else: return a


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [float('inf')] * N  # 最小化問題
    dp[0] = 0                # 初期条件
    
    for i in range(0,N):
        dp[i] = chmin(dp[i],dp[i-1]+abs(h_arr[i]-h_arr[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i],dp[i-2]+abs(h_arr[i]-h_arr[i-2]))
    cnt = dp[N-1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
import math
a,b=map(int,input().split())
print((a * b) // math.gcd(a, b))

### FIXED CODE ###

import fractions
a,b=map(int,input().split())
print((a * b) // fractions.gcd(a, b))
n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]
total=1
for j in a:
  taotal+=len(range(1,,j))
print(total)

### FIXED CODE ###

n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]
total=x
for j in a:
  total+=len(range(1,d+1,j))
print(total)
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()
A = [LIST() for i in range(N-1)]
P = [LIST() for i in range(Q)]

tree = defaultdict(list)

# ノードの重み

cnt = [0] * N

# tree 隣接リスト
for i in range(N-1):
    tree[A[i][0]-1].append(A[i][1]-1)
    tree[A[i][1]-1].append(A[i][0]-1)

for i in range(Q):
    cnt[P[i][0]-1] += P[i][1]

ans = [0] * N
q = deque([])
# 始点
q.append(0)
# 各頂点を見たかどうかのフラグ
checked = [0] * N
checked[0] = 1

while q:
    v = q.pop()
    checked[v] = 1
    for u in tree[v]:
        if checked[u] == 1:
            continue
        cnt[u] += cnt[v]
        q.append(u)
print(*cnt)


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()

tree = defaultdict(list)

# ノードの重み

cnt = [0] * N

# tree 隣接リスト
for i in range(N-1):
    a, b = LIST()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for i in range(Q):
    node, point = LIST()
    cnt[node-1] += point

ans = [0] * N
q = deque([])
# 始点
q.append(0)
# 各頂点を見たかどうかのフラグ
checked = [0] * N
checked[0] = 1

while q:
    v = q.pop()
    checked[v] = 1
    for u in tree[v]:
        if checked[u] == 1:
            continue
        cnt[u] += cnt[v]
        q.append(u)
print(*cnt)
a = list(map(int, input().split()))

if a[0]-a[1]==0 or a[1]-a[2]==0 or a[2]-a[3]==0:
    print("Bad")
else:
    print("Good")

### FIXED CODE ###

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

if a[0]-a[1]==0 or a[1]-a[2]==0 or a[2]-a[3]==0:
    print("Bad")
else:
    print("Good")
import math


N = int(input())
A = list(map(int, input().split()))
A.sort()
A_min = min(A)
del A[0]
A_min_2 = min(A)
print(math.gcd(A_min, A_min_2))

### FIXED CODE ###

def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x


N = int(input())
A = list(map(int, input().split()))
first_gcd = A[0]
for i in range(len(A)):
    first_gcd = gcd(first_gcd, A[i])
print(first_gcd)
def main():
    n, *i = map(int, open(0).read().split())
    a = i[:n]　　＃数列Aのリスト
    _ = i[n]　　　＃Qのこと
    s = sum(a)　　＃数列Aの総和

    m = [0] * (10 ** 5 + 1)　　＃Aは1<A<10^5なのでラベル用リストを作成
    for x in a:　　　　　　　　　＃Aの個数をラベル化。リストmは個数を記録している
        m[x] += 1

    ans = []
    for b, c in zip(*[iter(i[n + 1:])] * 2):
        m[c] += m[b]　　　　　　＃ｃの個数にbの個数を足し算
        s += (c - b) * m[b]　　＃s:数列Aの総和に、(c-b)×(bの個数)を足し算
        m[b] = 0　　　　　　　　　＃bの個数はゼロに
        ans.append(s)　　　　　　＃リストansにSの変化を記録していく

    print("\n".join(map(str, ans)))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
Q = int(input())
T = collections.Counter(A)
for i in range(Q):
    b, c = map(int, input().split())
    S += T[b]*(c-b)
    T[c] += T[b]
    T[b] = 0
    print(S)
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A < B:
  A_P = A + V * T
  B_P = B + W * T
  if A_P >= B_P:
    print("YES")
  else:
    print("NO")
else A > B:
  A_P = A - V * T
  B_P = B - W * T
  if A_P <= B_P:
    print("YES")
  else:
    print("NO")

### FIXED CODE ###

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A < B:
  A_P = A + V * T
  B_P = B + W * T
  if A_P >= B_P:
    print("YES")
  else:
    print("NO")
else:
  A_P = A - V * T
  B_P = B - W * T
  if A_P <= B_P:
    print("YES")
  else:
    print("NO")
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

C = Factorial(10 ** 6 + 5, MOD).comb

r1, c1, r2, c2 = map(int, input().split())

ans = 0
for i in range(c2 - c1 + 1):
    tmp = C(r2 + c2 + 1 - i, r2) - C(r1 + c2 - i, r1 - 1)
    # print (tmp, C(r2 + c2 + 1 - i, r2), C(r1 + c2 - i, r1 - 1))

    ans += tmp
    ans %= MOD

print (ans)


### FIXED CODE ###

r1, c1, r2, c2 = map(int, input().split())
MOD = 10 **9 + 7

ans = 0

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

F = Factorial(r2 + c2 + 3, MOD)

ans = F.comb(c1 + r1, c1) - F.comb(c1 + r2 + 1, c1) - F.comb(c2 + r1 + 1, c2 + 1) + F.comb(c2 + r2 + 2, c2 + 1)

print (ans % MOD)
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
s = S()

inf = 10**9+7

from math import factorial
def c(n, r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return a

result = 0
counts = collections.Counter(s)
red = [i for i in counts.values()]
tmp = 1
for i in red:
    tmp *= i
#  print('tmp', tmp)
for i in range(1, len(s)+1):
    #  print(i)
    #  import pdb
    #  pdb.set_trace()
    #  combis = list(itertools.combinations(counts, i))
    #  print('combis' ,combis)
    result += c(len(s), i)
    #  for combi in combis:
    #      #  print('combi', combi)
    #      tmp = 1
    #      for c in combi:
    #          #  print('c', c)
    #          tmp *= counts[c]
    #      #  print('tmp', tmp)
    #      result += tmp
if tmp != 1:
    for i in range(1, tmp):
        if tmp < i:
            result -= c(tmp, i)
print(int(result)%inf)


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
s = S()

inf = 10**9+7

counts = collections.Counter(s)
result = 1
for i in counts.values():
    result *= i+1
result -= 1
print(result%inf)
exit()
def read():
    N, H, W = list(map(int, input().strip().split()))
    A = []
    B = []
    for i in range(N):
        a, b = list(map(int, input().strip().split()))
        A.append(a)
        B.append(b)
    return N, H, W, A, B


def solve(N, H, W, A, B):
    count = 0
    for i in range(N):
        if A[i] >= H and B[i] >= W:
            count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    print(solve(inputs))


### FIXED CODE ###

def read():
    N, H, W = list(map(int, input().strip().split()))
    A = []
    B = []
    for i in range(N):
        a, b = list(map(int, input().strip().split()))
        A.append(a)
        B.append(b)
    return N, H, W, A, B


def solve(N, H, W, A, B):
    count = 0
    for i in range(N):
        if A[i] >= H and B[i] >= W:
            count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))
a = input()
b = a.splitlines()
N = int(b[0])
S = list(b[1])
K = int(b[2])
lit = S[K-1]
for i in range(N):
  if S[i] != lit:
    S[i] = '*'

print(''.join(S))

### FIXED CODE ###

N = int(input())
S = list(input())
K = int(input())
lit = S[K-1]
for i in range(N):
  if S[i] != lit:
    S[i] = '*'

print(''.join(S))
MOD = 10**9+7
facts = [1]
for i in range(1, 10**5+1):
    facts.append((i*facts[i-1])%MOD)
def nCk(n, k):
    if n < k or n == 0: return 0
    return (facts[n]*pow(facts[k], MOD-2, MOD)%MOD * pow(facts[n-k], MOD-2, MOD))%MOD

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

# Search doubling number and its indexes
indexes = [[] for _ in range(n+1)] # 0 to n:max(a)
for i in range(n+1):
    indexes[a[i]].append(i)
for idx in indexes:
    if len(idx) == 2: idxs = sorted(idx)

for k in range(1, n+1+1):
    p_all = nCk(n+1, k)
    p_double = nCk(n+1-(idxs[1]-idxs[0]+1), k-1)
    print((p_all-p_double)%MOD)


### FIXED CODE ###

MOD = 10**9+7
facts = [1]
for i in range(1, 10**5+2):
    facts.append((i*facts[i-1])%MOD)
def nCk(n, k):
    if n < k: return 0
    return (facts[n]*pow(facts[k], MOD-2, MOD)%MOD * pow(facts[n-k], MOD-2, MOD))%MOD

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

# Search doubling number and its indexes
indexes = [[] for _ in range(n+1)] # 0 to n:max(a)
for i in range(n+1):
    indexes[a[i]].append(i)
for idx in indexes:
    if len(idx) == 2: idxs = sorted(idx)

for k in range(1, n+1+1):
    p_all = nCk(n+1, k)
    p_double = nCk(n+1-(idxs[1]-idxs[0]+1), k-1)
    print((p_all-p_double)%MOD)
#import
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}
T = [int(input()) for _ in range(N)]


def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)


res = T[0] * T[1] // gcd(T[0], T[1])

for i in range(2, N):
    r = res * T[i] // gcd(res, T[i])
    res = max(r, res)

print(res)

### FIXED CODE ###

N = int(input())
T = [int(input()) for _ in range(N)]


def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)


if N == 1:
    print(T[0])
    exit()

res = T[0] * T[1] // gcd(T[0], T[1])

if N > 2:
    for i in range(2, N):
        r = res * T[i] // gcd(res, T[i])
        res = max(r, res)

print(res)
input = input()
if 0 <= input < 86400:
    hour = input / 3600
    minute = (input / 60) % 60
    seconde = input % 60
    print("%d:%d:%d" % (hour,minute,seconde))

### FIXED CODE ###

input = int(input())
if 0 <= input < 86400:
    hour = input / 3600
    minute = (input / 60) % 60
    second = input % 60
    print("%d:%d:%d" % (hour,minute,second))
N, Q = map(int, input().split())
s = '#' + input() + '#'
T = []
D = []
for t, d in [input().split() for _ in range(Q)]:
  T.append(t)
  D.append(-1 if d=='L' else 1)

#そのゴーレムがどちらかの端にたどり着けるかの関数
def canReachEnd(iL, dir):
  nowL = iL
  nowt = s[iL]
  for t, d in zip(T, D):
    if t == nowt:
      nowL += d
      nowt = s[nowL]
  if dir == 1 and nowL == N+1:
    return True
  elif dir == -1 and nowL == 0:
    return True
  else:
    return False

#1. iは左にたどり着くがi+1は辿りつかないようなiを探す
left = 0
right = N+1
while right > left+1:
  check = (left + right)//2
  if canReachEnd(check, -1):
    left = check
  else:
    right = check
leftborder = left

#2. jは右にたどり着くがj-1は辿りつかないようなjを探す
left = leftborder
right = N+1
while rigtht > left+1:
  check = (left+right)//2
  if canReachEnd(check, 1):
    right = check
  else:
    left = check
rightborder = right

dropcnt = 0
dropcnt += leftborder
dropcnt += (N-(rightborder-1))
print(N-dropcnt)


### FIXED CODE ###

N, Q = map(int, input().split())
s = '#' + input() + '#'
#room[0], [1~N], [N+1]と考える
#文字を取り出すとき:[1~N]
T = [] #Title[0～Q-1]
D = [] #Direction[0～Q-1] R:1, L:-1で表現
for t, d in [input().split() for _ in range(Q)]:
  T.append(t)
  D.append(-1 if d=='L' else 1)

#そのゴーレムがどちらかの端にたどり着けるかの関数
#True, Falseを返す
def canReachEnd(iL, dir):
  #iLは初期マス(1~N), dirは方向(L:-1, R:1)
  
  #nowL:今いるマスの位置
  nowL = iL
  #nowt:今いるマスに書いてある文字
  nowt = s[iL]
  for t, d in zip(T, D):
    if t == nowt:
      #左に動いても右に動いてもdを足せばok
      #端に落ちたら文字が'#'なので気にしない
      nowL += d
      nowt = s[nowL]
      
  if dir == 1 and nowL == N+1:
    return True
  elif dir == -1 and nowL == 0:
    return True
  else: return False
#たどり着けるかの関数終わり

#ここから二分探索で2つの「境目」を探す

#(1)「iは左に辿り着くがi+1は辿り着かない」iを探す
#何も辿り着かない場合はi=0とする？
#全部辿り着く場合はi=Nとする？
#leftとrightが隣接したときのleftを答えとする？
##すると、ありえるleftの範囲は0~N
left = 0
right = N+1
while right > left+1:
  check = (left+right)//2
  
  if canReachEnd(check, -1):left = check
  else: right = check
#答えを代入
leftborder = left


#(2)「jは右に辿り着くがj-1は辿り着かない」jを探す
#何も辿り着かない場合はj=N+1とする？
#全部辿り着く場合はj=1とする？
#leftとrightが隣接したときのrightを答えとする？
##すると、ありえるrightの範囲はleftborder+1~N+1
left = leftborder #(1)で左に辿り着くと分かった部分は省く
right = N+1
while right > left+1:
  check = (left+right)//2
  
  if canReachEnd(check, 1):right = check
  else: left = check
#答えを代入
rightborder = right

#二分探索終わり

#lbには左に辿り着く限界,rbには右に辿り着く限界が格納
#1~lbまでは全部左端に落ちる lb==0なら0
#rb~Nまでは全部右端に落ちる rb==N+1なら0

dropcnt = 0
dropcnt += leftborder
dropcnt += (N-(rightborder-1))
print(N-dropcnt)
from math import gcd
a, b = map(int, input().split())
g = gcd(a, b)
print(a * b // g)

### FIXED CODE ###

a, b = map(int, input().split())
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd(a, b)
print(lcm(a, b))
n=int(input())
r=input().split()
for i in range(r):
     r[i]=int(r[i])
s=sum(r)
m=min(r)
ma=max(r)
print(m ma s)


### FIXED CODE ###

n=int(input())
r=input().split()
for i in range(len(r)):
    r[i]=int(r[i])
s=sum(r)
m=min(r)
ma=max(r)
print(m,ma,s)
n, l = map(int, input().split())
pie = 0
min_aji = 100
for i in range(1, n+1):
    pie += l + i - 1
    if abs(l + i - 1) < min_aji:
        min_aji = abs(l + i - 1)
        apple = i
        
pie -= l + apple -1

print(pie)

### FIXED CODE ###

n, l = map(int, input().split())
aji = []

for i in range(1, n+1):
    aji.append(l + i - 1)

aji.sort(key=abs)
print(sum(aji[1:]))
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 0
for i in range(n):
  d = x[i+k-1] - x[i] + min(abs(x[i]), abs(x[i+k-1]))
  ans = min(ans, d)
  
print(ans)

### FIXED CODE ###

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

ans = 10**9
for i in range(n-k+1):
  d = x[i+k-1] - x[i] + min(abs(x[i]), abs(x[i+k-1]))
  ans = min(ans, d)
  
print(ans)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

x = [input() for i in range(2)]
if x[0][0] == x[1][2] and x[0][1] == x[1][1] and x[1][0] == x[0][2]:
  print('YES')
else:
  print('NO')
N = int(input())
if 0 <= N <= 1000:
  print(1000 - N)
elif 1001 <= N <= 2000:
  print(2000 - N)
elif 2001 <= N <= 3000:
  print(3000 - N)
elif 3001 <= N <= 4000:
  print(4000 - N)
elif 4001 <= N <= 5000:
  print(5000 - N)
elif 5001 <= N <= 6000:
  print(6000 - N)
elif 6001 <=N <= 7000
  print(7000 - N)
elif 7001 <= N <= 8000:
  print(8000 - N)
elif 8001 <= N <= 9000:
  print(9000 - N)
else:
  print(10000 - N)

### FIXED CODE ###

N = int(input())
if 0 <= N <= 1000:
  print(1000 - N)
elif 1001 <= N <= 2000:
  print(2000 - N)
elif 2001 <= N <= 3000:
  print(3000 - N)
elif 3001 <= N <= 4000:
  print(4000 - N)
elif 4001 <= N <= 5000:
  print(5000 - N)
elif 5001 <= N <= 6000:
  print(6000 - N)
elif 6001 <=N <= 7000:
  print(7000 - N)
elif 7001 <= N <= 8000:
  print(8000 - N)
elif 8001 <= N <= 9000:
  print(9000 - N)
else:
  print(10000 - N)