peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, K = map(int, input().split())
MOD = 10**9 + 7
nac = [0] * (N + 2)
ninv = [0] * (N + 2)
inv = [0] * (N + 2)
nac[0],nac[1] = 1,1
inv[0] = 1
ninv[0],ninv[1] = 1,1

for i in range(2, N + 2):
    nac[i] = (nac[i-1] * i % MOD)
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD
    ninv[i] = int(ninv[i - 1] * inv[i] % MOD)

ret = 0
for i in range(K,N+2):
    ret += (nac[N + 1] / nac[i]/ nac[N+1 - i])
print(int(ret))
# Judge status: Wrong Answer
N,A,B = map(int,input().split())
print((N-1)*B+A-(N-1)*A-B+1)
# Judge status: Accepted
n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t==h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

dp[0] = 1


for v in range(1,N+1):
    if v in A:
        continue
    dp[v] = (dp[v] + dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v] + dp[v-2])%(1000000007)
print(dp)
print(dp[N])
# Judge status: Wrong Answer
N=int(input())
count=0
for k in range(1,N):
    for a in range (1,k):
        if k%a==0:
            count=count+1
        else:
            continue
print(count)
# Judge status: Accepted
n = int(input())
import collections
d = collections.defaultdict(int)
ans = 0
for i in range(n):
    sl = sorted([j for j in input()])
    ss = ''.join(sl)
    ans += d[ss]
    d[ss] += 1

print(ans)
# Judge status: Wrong Answer
n = int(input())
kuku = set()

for i in range(1,9):
    for j in range(1,9):
        kuku.add(i*j)

if n in kuku:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def resolve():
    S = input()
    table=[0]*2019
    table[0]=1
    x = 0
    x_10 =1
    for i in S[::-1]:
 
        x = (x+ int(i)*x_10)%2019
 
        table[x]+=1
 
        x_10*=10
        x_10 %= 2019
 
    ans =0
    for i in table:
        ans += i*(i-1)//2
    
    print(ans)
 
 
 
if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
l,r = map(int,input().split())
if l - r >= 2019:
     print(0)
else:
     s = l % 2019

     if s + l - r >= 2019:
          print(0)
     else:
          print(s*(s+1))
# Judge status: Accepted
import sys

input = sys.stdin.readline

S = input().strip()

if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
S = str(input())

a = []



for i in range(0,len(S)-2):
  a.append(abs(int(S[i:i+3])-753))
  
print(min(a))
# Judge status: Wrong Answer
def solve(n):
    if n == 1:
        return 0
    res = 0
    for i in range(2, int(n ** 0.5) + 1):
        cnt = 1
        while n % (i ** cnt) == 0:
            n //= i ** cnt
            res += 1
            cnt += 1
    return max(res, 1)

n = int(input())
ans = solve(n)
print(ans)
# Judge status: Accepted
H,A=map(int,input().split())
print((H+A-1)//A)
# Judge status: Wrong Answer
N = int(input())
if N < 105:
    print(0)
elif N < 135:
    print(1)
elif N < 165:
    print(2)
elif N < 189:
    print(3)
elif N >= 195:
    print(4)
# Judge status: Wrong Answer
N,T = input().split(" ")
N,T = int(N),int(T)

time = dict()
for i in range(N):
	c,t = input().split(" ")
	time[int(c)] = int(t)
for key, value in sorted(time.items(), key=lambda item: item[1]):
	if value <= T:
		print(value)
		break
	else:
		print("TLE")
		break
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    S, W = map(int, input().split())
    print("unsafe"if S <= W else "safe")


if __name__ == "__main__":
    main()
# Judge status: Accepted
N, R = map(int, input().split())
print(R) if N >= 10 else print(R+(100*(10-N)))
# Judge status: Accepted
n,k,x,y=(int(input()) for i in range(4))
if n<=k:
    ans=n*x
else:
    ans=k*x+(n-k)*y
print(ans)
# Judge status: Accepted
x,y = list(map(int, input().split()))
ans=0
if abs(x) < abs(y):
    if x<0:
        ans+=1
    ans+=abs(y)-abs(x)
    if y<0:
        ans+=1
elif abs(x) > abs(y):
    if x>0:
        ans+=1
    ans+=abs(x)-abs(y)
    if y>0:
        ans+=1
else:
    if x!=y:
        ans+=1
print(ans)
# Judge status: Wrong Answer
import sys
a1=sys.stdin.readline()
a2=list(a1)
b=[ord(x) for x in a2]
b.sort()
if b[0]==b[1] and b[2]==b[3] and b[0]!=b[3] and b[1]!=b[2] and len(a2)==4:
    print("Yes")
elif len(a2)==4:
    print("No")
else:
    print("Error")
# Judge status: Accepted
A , B , C , K = map ( int  ,input().strip().split(" ") ) 
l = [ 1 , 0 , -1 ] ;
t = 0 

for ( c,r ) in zip ( l , ( A, B , C ) ) :

	if r >= K :
		t += K * c ;
		break ;
	else :
		K -= r ;
		t += r * c ;
print ( t ) ;
# Judge status: Accepted
N,K = map(int, input().split())
A = [int(i) for i in input().split()]

if N == K:
    print(1)
else:
    cnt = 1
    N -= K
    while N > 0:
        cnt += 1
        N -= K
        N += 1
    print(cnt)
# Judge status: Accepted
D, T, S = map(int, input().split())
if T*S >= D:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a, b, c = map(int, input().split())
ans = float('inf')
ans = min(ans, a * b * ((c + 1) // 2) - a * b * (c // 2))
ans = min(ans, b * c * ((a + 1) // 2) - b * c * (a // 2))
ans = min(ans, c * a * ((b + 1) // 2) - c * a * (b // 2))
print(ans)
# Judge status: Accepted
X, Y = map(int, input().split())
ans = 0
while X <= Y:
    X *= 2
    ans += 1

print(ans)
# Judge status: Accepted

# 文字列の入力
s = input()
# 出力
if s == 'ABC':
    print('ARC')
elif s == 'ARC':
    print('ABC')
# Judge status: Wrong Answer
A,B = map(int,input().split())

if A>B:
    print("Alicd")
elif A<B:
    print("Bob")
else:
    print("Draw")
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())

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

X.sort()

if N >= M:
    print(0)
    sys.exit()

dist = []

for i in range(len(X)-1):
    dist.append(X[i+1] - X[i])

dist.sort(reverse=True)

ans = X[-1] - X[0]
for i in range(N-1):
    ans -= dist[i]
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
step = 0
height = 0
for i in range(N):
  if A[i] <= height:
    step += height - A[i]
  else:
    height = A[i]
print(step)
# Judge status: Wrong Answer
i = list(map(int, input().split()))
k=int(i[0]/2)
if i[0]%2==1:
    for j in range(i[1]):
        print(k-j, k+1+j)
else:
    for j in range(i[1]):
        if (k-j)*2!=(k+1+j):
            print(k-j, k+1+j)
# Judge status: Wrong Answer
import re
a,b = list(map(int,input().split()))
s = input()
if re.match(r"[1-9][1-9]*",s[:a]):
  if s[a]=="-":
    if re.match(r"[1-9][1-9]*",s[(a+1):]):
      print("Yes")
      exit()
print("No")
# Judge status: Accepted
N = int(input())
h = list(map(int, input().split()))
list = [0 for _ in range(N)]
list[0] = 0
list[1] = abs(h[1]-h[0])
for i in range(2, N):
  list[i] = min(abs(h[i] - h[i-1]) + list[i-1], abs(h[i] - h[i-2]) + list[i-2])
print(list[N-1])
# Judge status: Accepted
n,m=map(int,input().split())
if n%2==1:
    x=[f"{i+1} {n-i}" for i in range(m)]
    print(" ".join(x))
else:
    x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
    print(" ".join(x))
# Judge status: Accepted
N, K = map(int, input().split())
D = list(input().split())

while True:
    n = str(N)
    for i in range(K):
        f = 0
        if D[i] in n:
            N += 1
            f = 1
            break
    if f == 0:
        break

print(N)
# Judge status: Wrong Answer
n, k = map(int, input().split())
d = list(input().split())
n = 1000
flag = True
while flag:
    flag2 = True
    for si in str(n):
        if si in d:
            n += 1
            flag2 = False
            break
    if flag2:
        break
    else:
        flag = True
            
print(n)
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]

A.sort(reverse=True)
ret = A[0]
c = N - 2
i = 1
while c :
  if c >= 2 :
    ret += A[i] * 2
    c -= 2
  else :
    ret += A[i]
    c -= 1
  i += 1

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

diff = b - a
sum = 0
for i in range(1, diff, 1):
  sum += i

ans = sum - a
print(ans)
# Judge status: Wrong Answer
def frog(arr):
    
    n=len(arr)
    if n<=1:
        return 0
    dp=[0]*(n+1)
#     dp[2]=abs(arr[0]-arr[1])
#     if n==2:
#         return dp[2]
    for i in range(2,n+1):
        
        dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]))
    return dp[n]
n=int(input())
arr=[int(i) for i in input().split()]
frog(arr)
# Judge status: Accepted
h,n=map(int,input().split())
a=[int(x) for x in input().split()]
if sum(a) >= h:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
count=[0 for _ in range(100001)]
for x in a:
    count[x]+=1
    count[x+1]+=1
    if x>0:
        count[x-1]+=1
print(max(count))
# Judge status: Wrong Answer
h1,m1,h2,m2,k=map(int,input().split())
s=abs(h2-h1)*60+abs(m2-m1)
n=s-k
print(n)
# Judge status: Accepted
a,b,x = map(int, input().split())
if a%x == 0:
    buf1 = a//x - 1
else:
    buf1 = a//x

buf2 = b//x

print(buf2 - buf1)
# Judge status: Accepted
a, b, c = map(int, input().split())
ans = None
if a + b >= c:
    ans = "No"
elif 4 * a * b < c ** 2 + (a + b) ** 2 - 2 * c * (a + b):
    ans = "Yes"
else:
    ans = "No"
print(ans)
# Judge status: Accepted
N=int(input())

ans=1
cnt=0
for i in range(1,N+1):
    tmp=0
    n=i
    while True:
        if n%2==0:
            tmp+=1
        else:
            break
        n//=2
    if tmp>cnt:
        ans=i
        cnt=tmp
print(ans)
# Judge status: Accepted
import sys
from collections import Counter

n, *a = map(int, sys.stdin.read().split())

def main():
    b = [a[i] + i for i in range(n)]
    c = [i - a[i] for i in range(n)]
    cb = Counter(b)
    cc = Counter(c)
    tot = 0
    for v, c in cb.items():
        tot += c * cc[v]
    print(tot)
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()

if s[0] == "A" and s[2:-1].count("C") == 1:
	tmp = s.replace("A","").replace("C","")
	if tmp.islower():
		print("AC")
	else:
		print("WA")
else:
	print("WA")
# Judge status: Accepted
ans=""
n=int(input())
s=[input() for _ in range(n)]
from collections import Counter
d=Counter(s[0])
for i in s[1:]:
    d&=Counter(i)
for i ,k in sorted(d.items()):
    ans+=i*k
print(ans)
# Judge status: Accepted
a,b=2,1
for _ in range(int(input())-1): a,b=b,a+b
print(b)
# Judge status: Wrong Answer
n = int(input())
sp = [input().split() for _ in range(n)]

for i in range(n):
    sp[i][1] = int(sp[i][1])
    sp[i] = sp[i]+[i+1]
    
sp_s0 = sorted(sp, key=lambda x:(x[0], -x[1]), reverse=False)
print(sp_s0)

for i in range(n):
    print(sp_s0[i][2])
# Judge status: Accepted
N = int(input())
S = str(input())

flag = False
half = (N+1) // 2
if S[:half] == S[half:N]:
  flag = True
if flag:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
#088_C
c = [sum(list(map(int, input().split()))) for _ in range(3)]
print('Yes' if sum(c)%3==0 else 'No')
# Judge status: Wrong Answer
N,M = map(int, input().split())
A = [int(N) for N in input().split()]
X=0
F=int(sum(A)/(4*M))
for i in range(N):
    if A[i] >= F:
        X+=1
if X>=M:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
s=input()
maxi=0
cnt=0
for i in range(len(s)):
  if s[i]=='I':
    cnt+=1
    if maxi < cnt:
      maxi = cnt
  elif s[i]=='D':
    cnt-=1
print(maxi)
# Judge status: Accepted
c=str(input())

if c=='a' or c=='i' or c=='u' or c=='e' or c=='o':
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
from collections import deque
import bisect

N = int(input())
table = deque()
for n in range(N):
    a = int(input())
    if n == 0:
        table.append(a)
    else:
        if a <= table[0]:
            table.appendleft(a)
        else:
            table[bisect.bisect_left(table, a)-1] = a
            
print(len(table))
# Judge status: Accepted
import sys

n,m=map(int,input().split())
ans=[0]*(m+1)
output=0

for i in range(n):
    k=list(map(int,input().split()))
    for j in range(1,len(k)):
        ans[k[j]]+=1

for i in ans:
    if i==n:
        output+=1

print(output)
# Judge status: Accepted
N,A=[int(input()) for i in range(2)]
print('Yes'if N%500<=A else 'No')
# Judge status: Wrong Answer
N = int(input())
As = [int(n) for n in input().split()]
# len(As) = N
# Ai = 身長
c = 0
for i, ai in enumerate(As):
    # i + ai = 最低これだけ先が無いとダメ
    j0 = i + ai
    if j0 >= N-1:
        continue
    j = 1
    while True:
        if j == As[j0+j]:
            c += 1
        if j0+j >= N-j:
            break
        if N-j0-j == As[N-j]:
            c += 1
        j+=1
print(c)
# Judge status: Accepted
S = input()
if S == "hi" or S == "hihi" or S == "hihihi" or S == "hihihihi" or S == "hihihihihi" :
    print("Yes")
else:
    print("No")
# Judge status: Accepted
print("ABC" if input() == "ARC" else "ARC")
# Judge status: Accepted
import math
a, b, x = map(int, input().split())

def fm(a, b, x):
    return (2*x / (a**2)) - b

def fn(a, b, x):
    return 2*x / (a*b)

if fm(a, b, x) >= 0:
    ans = math.degrees(math.atan((b - fm(a, b, x)) / a))
else:
    ans = math.degrees(math.atan(b / fn(a, b, x)))

print(ans)
# Judge status: Accepted
N = int(input())
ans = ((N + 1) // 2) / N
print(ans)
# Judge status: Accepted
N , K = map(int,input().split())
S = list(input())
old_s = S[0]
count = 0
for s in S:
    if old_s!=s:
        count+=1
    old_s = s

print((N-1)-count+min(2*K,count))
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i]-(i+1))
B.sort()
if N%2==0:
  a=N/2
  b=int((B[int(a)]+B[int(a-1)])/2)
else:
  a=(N+1)/2
  b=B[int(a-1)]
for i in range(N):
  B[i]=abs(B[i]-b)
print(sum(B))
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = min(a) + min(b)

c_min = 200001
for _ in range(M):
    x, y, c = map(int, input().split())
    c_min = min(c_min, a[x-1] + b[y-1] - c)

result = min(s, c_min)
print(result)
# Judge status: Accepted
X,Y = map(int,input().split())
if X%Y==0:
    print(-1)
else:
    print(X)
# Judge status: Wrong Answer
s=str(input().split())
s=sorted(s)
if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,m,x = map(int,input().split())
#a_L = list(map(int,input().split()))
import itertools
#print(L)
a_L = []
c_L = []

import numpy as np


        

for i in range(n):
    tmp= list(map(int,input().split()))
    c = tmp[0]
    tmpL = tmp[1:]
    a_L.append(tmpL)
    c_L.append(c)
print(-1)
# Judge status: Accepted
n,x = map(int,input().split())
l = list(map(int,input().split()))
n,c = 0,1
for i in l:
    n+=i
    if(n<=x): c+=1
    else: break
print(c)
# Judge status: Accepted
n,k=map(int,input().split())
A = list(map(int,input().split()))
n -= k
k -= 1
ans = 1
ans += (n+k-1)//k
print(ans)
# Judge status: Wrong Answer
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
B = [0 for _ in range(N)]
for i in range(N):
    B[A[i]-1] = i+1
print(B)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = input()
a -= 1; b -= 1; c -= 1; d -= 1; e = 1
for i in range(b, min(c, d)+1):
    if s[i-1] == "." and s[i] == "." and s[i+1] == ".": e = 0
if c < d: e = 0
for i in range(a, max(c, d)):
    if s[i] == "#" and s[i+1] == "#": e = 1
print("Yes") if e == 0 else print("No")
# Judge status: Accepted
import math

N,M = map(int,input().split())
#Nは偶数
#Mは奇数

#偶数偶数
if N >= 2:
  Nf = math.factorial(N)//(math.factorial(N-2)*2)
else:
  Nf = 0
#奇数奇数
if M >= 2:
  Mf = math.factorial(M)//(math.factorial(M-2)*2)
else:
  Mf = 0
ans = int(Nf + Mf)
print(ans)
# Judge status: Wrong Answer
X=int(input())
ans=0
for i in range(X+1):
    if i*i<=X:
        sum=i*i
        for j in range(X):
            if i*(i*j)>X:
                break
            sum=max(sum,i*(i*j))
    else:
        break
    ans=max(ans,sum)

print(sum)
# Judge status: Accepted
n, k = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])
sm = 0
for a, b in ab:
    sm += b
    if sm >= k:
        print(a)
        break
# Judge status: Accepted
def solve():
  ans = 0
  N = int(input())
  A = [0]*N
  B = [0]*N
  for i in range(N):
    A[i],B[i] = map(int, input().split())
  for i in range(N-1,-1,-1):
    A[i] += ans
    if A[i]%B[i]>0:
      ans += B[i]-A[i]%B[i]
  return ans
print(solve())
# Judge status: Wrong Answer
N = input()

if N <= str(999):
    print('ABC')

if N >= str(1000):
    print('ABD')
# Judge status: Accepted
import collections

n=int(input())
a=list(map(int,input().split()))
a=collections.Counter(a)
a=sorted(a.items(),reverse=True)
#print(a)

tm=0

for i in range(n):
    if a[i][1]>=4 and tm==0:
        print(a[i][0]*a[i][0])
        exit()
    elif a[i][1]>=2:
        if tm==0:
            tm=a[i][0]
        else:
            print(tm*a[i][0])
            exit()

print("0")
# Judge status: Wrong Answer
n,m = list(map(int, input().split()))
A = list(map(int,input().split()))
A = sorted(A,reverse=True)


ans = "Yes"
sumA = sum(A)
compare = sumA//(4*m)
for i in range(m):
    if A[i] < compare:
        ans = "No"

print(ans)
# Judge status: Accepted
N = int(input())
A = []
D = {}
cnt = 0

for i in range(N):
    S=''.join(sorted(input()))#文字列で受け取る
    A.append(S)

for s in A:
    if s in D:
        cnt += D[s]
        D[s] += 1 #D[s]=これまでのs登場回数
    else:
        D[s]=1
print(cnt)
# Judge status: Wrong Answer
k,x = map(int,input().split())

c = []

for i in range(-k+1,k):
  c.append(str(x-i))
  
c.sort()
print(' '.join(c))
# Judge status: Accepted
a=int(input())
s=input()
if a<3200:
    print('red')
else:
    print(s)
# Judge status: Wrong Answer
import math

a, b, x = map(int,input().split())
v = a*a*b

if x > v/2:
    y = 2*(b-(x/(a*a)))
    naname = math.sqrt((y*y) + (a*a))
    cosine = a/naname
    print(math.degrees(math.acos(cosine)))
elif x < v/2:
    y = 2*x/(b*a)
    naname = math.sqrt((y*y)+(b*b))
    cosine = b / naname
    print(90-math.degrees(math.acos(cosine)))
else:
    print(3)
    naname = math.sqrt((a*a)+(b*b))
    cosine = a/naname
    print(math.degrees(math.acos(cosine)))
# Judge status: Accepted
a,b=list(map(int,input().split()));
hh=False;
if (a>9 or b>9):
	print(-1);
else:
	print(a*b);
# Judge status: Wrong Answer
n = int(input())

answer = 0
for i in range(1,n+1):
  if (i**2) > n:
    answer = (i-1)**2
  else :
    break

print(answer)
# Judge status: Accepted
n = int(input()) 
h = list(map(int,input().split()))
c = []

for i in range(n):
  c.append([h[i],i+1])
  
c.sort()
for i , k in c:
  print(k)
# Judge status: Accepted


def resolve():
    X,Y=map(int,input().split())

    count =0
    while X<=Y:
        count +=1 
        X*=2
    print(count)



if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
n = int(input())
w = list(map(int, input().split()))

a = 0
b = sum(w)
for i in w:
  a += i
  b -= i
  if a > b:
    break
print(abs(a-b))
# Judge status: Accepted
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

a = ri()

print(a+a**2+a**3)
# Judge status: Accepted
s = int(input())
if s == 10**18:
    print(0, 0, 10**9, 0, 0, 10**9)
    exit()
t = 10**9
a, b = s // t + 1, t - s % t
print(0, 0, 1, t, a, b)
# Judge status: Wrong Answer
n=int(input())
c=list(input())
r=0
for i in range(n):
     if c[i]=='W':
          r=i
num=0
for i in range(n):
     if c[i]=='W':
          num+=1

if num>=n-r:
     print(num-1)
else:
     print(num)
# Judge status: Accepted
n, x = map(int, input().split())
A = sorted([int(i) for i in input().split()])
# print(A)
cnt = 0
for e in A:
    if e <= x:
        x = x - e
        cnt += 1
if cnt == n and x > 0:
    print(cnt-1)
else:
    print(cnt)
# Judge status: Accepted
x = list(map(str, input().rstrip()))

stock = 0
rest = 0
for i in x:
    if i == "S":
        stock += 1
    elif i == "T" and stock >= 1:
        stock -= 1
    else:
        rest += 1

print(stock + rest)
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
diff = 1000
ans = 0

for i in range(n):
    if diff > abs(a - (t - h[i]*0.006)):
        diff = abs(a - (t - h[i]*0.006))
        ans = i + 1

print(ans)
# Judge status: Accepted
def main():
    n = int(input())
    s = input()

    ans = 0
    for i in range(n):
        x = set()
        for j in range(i):
            x.add(s[j])
        y = set()
        for j in range(i, n):
            if s[j] in x:
                y.add(s[j])
        ans = max(ans, len(y))

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input());
arr = list(map(int, input().split()));
arr.sort();
ans = 0;
for i, x in enumerate(arr):
  arc_arr = list(filter(lambda target: target >= x, arr));
  if len(arc_arr) == n - len(arc_arr): ans = x - arr[i-1]
print(ans);
# Judge status: Wrong Answer
n = list(input())
print('YES' if '9' in n else 'NO')
# Judge status: Wrong Answer
n,t = map(int,input().split())
ans = 10000
for i in range(n):
    c,ti = map(int,input().split())
    if ti <= t:
        ans = min(c,ans)
print(ans)
# Judge status: Accepted
D, N = map(int,input().split())

cnt = 0

for i in range(1, 1500000):
    if i%(100**D) == 0 and  i%(100**(D+1)) != 0:
        cnt += 1
        if cnt == N:
            print(i)
            break
# Judge status: Accepted
from collections import deque
S = deque(input())
Q = int(input())
q = [input().split() for _ in range(Q)]
flag = True
for x in q:
    if x[0] == "1":
        if flag: flag = False
        else: flag = True
    else:
        if x[1] == "1":
            if flag: S.appendleft(x[2])
            else: S.append(x[2])
        else:
            if flag: S.append(x[2])
            else: S.appendleft(x[2])
s = list(S)
if not flag: s = s[::-1]
print("".join(s))
# Judge status: Accepted
A, B = map(int, input().split())
ans = 0
for a in range(0, 2):
    if A > B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1

print(ans)
# Judge status: Wrong Answer
A, B = map(int, input().split())
if A >= 13:
    print(B)
elif A < 6:
    print(0)
else:
    print(B / 2)
# Judge status: Wrong Answer
from bisect import bisect

N, *P = map(int, open(0).read().split())

INF = 10 ** 6
dp = [INF] * (N + 1)
for i in range(N):
    dp[bisect(dp, -P[i])] = -P[i]
    
print(sum(dp[i] < INF for i in range(N)))
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

rem = x
give = 0

for i in range(n):
    rem -= a[i]
    give += 1
    if rem < 0:
        break

if rem != 0:
    give -= 1

print(give)
# Judge status: Wrong Answer
import math

n = int(input())

x = []
y = []
sum = 0

#座標入力
for i in range(n):
	a, b = map(int, input().split())
	x.append(a)
	y.append(b)

#距離の総和
for i in range(n):
	for j in range(n):
		num = math.factorial(n-1)									
		dist = ((x[i]-x[j])^2+(y[i]-y[j])^2)**0.5
		sum+= num*dist

print(sum/math.factorial(n))
# Judge status: Accepted
n,k = map(int, input().split())
a = list(map(int, input().split()))
a = [i-1 for i in a]
num = [0] * (n)
num[0] = 1
now = 0
looped = 0
for i in range(2,k+2):
  nex = a[now]
  if num[nex]:
    start = num[nex]
    cycle = i - num[nex]
    v = (k+1-i) % cycle + start
    ans = num.index(v) + 1
    looped = 1
    break
  else:
    num[nex] = i
    now = nex
if looped:
  print(ans)
else:
  print(now+1)
# Judge status: Accepted
a,b,k = map(int,input().split())
for i in range(101,0,-1):
    if a%i==0 and b%i==0:
        k-=1
        if k==0:
            print(i)
            exit()
# Judge status: Accepted
s = input()
cnt = 0
n = len(s)
al = [0]*(n+1)
ag = [0]*(n+1)
for i in range(n):
    if s[i] == '<':
        al[i+1] = al[i] + 1
for i in range(n-1, -1, -1):
    if s[i] == '>':
        ag[i] = ag[i+1] + 1
a = [x if x > y else y for x, y in zip(al, ag)]
print(sum(a))
# Judge status: Accepted
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ab.reverse()
ans=0
for i in range(n):
  d=ab[i][0]+ans
  if d%ab[i][1]!=0:
    ans+=ab[i][1]-d%ab[i][1]
print(ans)