Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

for i in range(A, B+1):
  if i < A + K or i > B - K:
    print(i)


### FIXED CODE ###

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

l = B - A + 1

if l == 1:
  print(A)
elif l == 2:
  print(A)
  print(B)
else:
  if (l+1)//2 <= K:
    for i in range(A, B+1):
      print(i)
  else:
    for i in range(A, A+K):
      print(i)
    for i in range(B-K+1, B+1):
      print(i)
### BUGGY CODE ###

a,b,k=map(int,input().split())
for i in range (k):
	if a>0:
		a-=1
	elif b>0:
		b-=1
print(a,b)

### FIXED CODE ###

a,b,k=map(int,input().split())
if k<=a:
	A=a-k
	B=b
elif k>=a and k-a<=b:
	A=0
	B=b+a-k
else:A=B=0
print(A,B)
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline
  N=int(input())
  A=list(map(int,input().split()))
  def lcm(a,N):
      from fractions import gcd
      x = a[0]
      y=  a[N//2]
      for i in range(1, N//2):
          x = (x * a[i]) // gcd(x, a[i])
          y = (y * a[i+N//2]) // gcd(y, a[i+N//2])
      y = (y * a[-1]) // gcd(y, a[-1])
      return (x*y)//gcd(x,y)
  z=lcm(A,N)
  MOD=10**9+7
  ans=0
  import numpy as np
  A=np.array(A)
  B=z//A%MOD
  print(sum(B)%MOD)
  
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  MOD=10**9+7
  N=int(input())
  A=list(map(int,input().split()))
  def lcm(a,N):
      from fractions import gcd
      x = a[0]
      y=  a[N//2]
      for i in range(1, N//2):
          x = (x * a[i]) // gcd(x, a[i])
          y = (y * a[i+N//2]) // gcd(y, a[i+N//2])
      y = (y * a[-1]) // gcd(y, a[-1])
      return (x*y)//gcd(x,y)
  z=lcm(A,N)
  ans=0
  for i in range(N):
    ans+=z//A[i]
  print(ans%MOD)
  
if __name__=='__main__':
  main()
### BUGGY CODE ###

from collections import Counter

def main():
    n = int(input())
    a = list(map(int,input().split()))
    for k in range(n):
        a_ = a[0:k]+a[k+1:]
        c = Counter(a_)
        s = 0
        for k in c.keys():
            cnt = c[k]
            if cnt>1:
                s+=cnt*(cnt-1)//2
        print(s)
            
if __name__ == "__main__":
    main()

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
import collections
C = collections.Counter(a)
S = 0
for i in C.keys():
    S += C[i]*(C[i]-1)//2

for i in range(n):
    A = a[i]
    print(S-C[A]+1)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def main():
    N = int(input())
    L = [int(i) for i in input().split()]

    count = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            for k in range(j + 1, N):
                sum = L[i] + L[j]
                sub = abs(L[i] - L[j])
                if sub < L[k] < sum:
                    count += 1
    print(count)





if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

INF = 2 * 10 ** 3 + 1

def main():
    N = int(input())
    L = [int(i) for i in input().split()]
    L.sort()

    # True ---- False
    def is_ok_top(mid: int, a: int, b: int):
        # 検索対象の外にあるものは先に弾く(リストのインデックスなんかだとout of rangeするので)
        if mid < 0:
            return True
        elif mid >= N:
            return False
        return L[mid] < L[a] + L[b]

    def binSearch_top(ok: int, ng: int, a: int, b: int):
        #print(ok, ng)              # はじめの2値の状態
        while abs(ok - ng) > 1:     # 終了条件（差が1となり境界を見つけた時)
            mid = (ok + ng) // 2
            if is_ok_top(mid, a, b):
                ok = mid            # midが条件を満たすならmidまではokなのでokの方を真ん中まで持っていく
            else:
                ng = mid            # midが条件を満たさないならmidまではngなのでngの方を真ん中まで持っていく
            #print(ok, ng)          # 半分に切り分ける毎の2値の状態
        return ok    

    count = 0
    for a in range(0, len(L) - 2):
        for b in range(a + 1, len(L) - 1):
            count += binSearch_top(-1, INF, a, b) - b

    print(count)







if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

ans=0
for i in range(n-k+1):
  tmp=0
  for j in range(k):
    tmp+=((1/2)*P[i+j]*(P[i+j]+1)) / P[i+j]
  ans=max(ans,tmp)
print(ans)

### FIXED CODE ###

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

dp=[0]*n
ans,total=0,0
for i in range(n):
  dp[i]=((1/2)*P[i]*(P[i]+1)) / P[i]
  if i>=k:
    ans=max(ans,total)
    total-=dp[i-k]
  total+=dp[i]
ans=max(ans,total)
print(ans)
### BUGGY CODE ###

from sys import stdin
n=int(stdin.readline().rstrip())
l=[int(x) for x in stdin.readline().rstrip().split()]
print(*[l.index(i)+1 for i in range(1,n+1)],sep=" ")

### FIXED CODE ###

def main():
  n=int(input())
  l=list(map(int,input().split()))
  k=[0]*n
  for i in range(1,n+1):
    k[l[i-1]-1]=str(i)
  print(" ".join(k))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import defaultdict

N, M = map(int, input().split())
# Aは昇順に並べる
A = list(sorted(map(int, input().split())))

# B,Cの対応辞書を作り、C順に並べる
counter = defaultdict(int)
for _ in range(M):
    B, C = map(int, input().split())
    counter[C] += B
c_list = list(sorted(counter.keys(), reverse=True))

# Cを大きい順に個数分並べたリストを作る
moves = []
n = 0
for c in c_list:
    b = counter[c]
    if n + b < N:
        p = b
    else:
        p = N - n
    for i in range(p):
        moves.append(c)

# AとCを小さい順に比較
siz = min(N, len(moves))
for i in range(siz):
    # Aの小さいものを上書き
    A[i] = max(A[i], moves[i])

print(sum(A))


### FIXED CODE ###

from collections import defaultdict

N, M = map(int, input().split())
# Aは昇順に並べる
A = list(sorted(map(int, input().split())))

# B,Cの対応辞書を作り、C順に並べる
counter = defaultdict(int)
for _ in range(M):
    B, C = map(int, input().split())
    counter[C] += B
c_list = list(sorted(counter.keys(), reverse=True))

# Cを大きい順に個数分並べたリストを作る
moves = []
n = 0
for c in c_list:
    b = counter[c]
    if n + b < N:
        p = b
    else:
        p = N - n
    for i in range(p):
        moves.append(c)
    if len(moves) >= N:
        break

# AとCを小さい順に比較
siz = min(N, len(moves))
for i in range(siz):
    # Aの小さいものを上書き
    A[i] = max(A[i], moves[i])

print(sum(A))
### BUGGY CODE ###

import sys


def factorial(N: int, mod: int) -> int:
    res = 1
    for i in range(1, N+1):
        res *= i
        res %= mod
    return res


N = int(input())
S = input()

if S[0] == 'W' or S[-1] == 'W':
    print(0)
    sys.exit()

op = [0]*(2*N)
op[0] = False
ct_L = 1
ans = 1
for i in range(1, 2*N):
    if S[i] == S[i-1]:
        if op[i-1] is False:
            op[i] = True
            ans *= ct_L
            ct_L -= 1
        else:
            op[i] = False
            ct_L += 1
    else:
        if op[i-1] is False:
            op[i] = False
            ct_L += 1
        else:
            op[i] = True
            ans *= ct_L
            ct_L -= 1

if op.count(True) != N:
    print(0)
    sys.exit()

mod = 10**9+7
print(factorial(N, mod) * ans % mod)


### FIXED CODE ###

import sys
from math import factorial

N = int(input())
S = input()
mod = 10**9+7

if S[0] == 'W' or S[-1] == 'W':
    print(0)
    sys.exit()

op = "L"
for i in range(1, 2*N):
    if S[i] == S[i-1]:
        op += 'R' if op[i-1] == 'L' else 'L'
    else:
        op += 'R' if op[i-1] == 'R' else 'L'

if op.count('L') != N:
    print(0)
    sys.exit()

ct_L, ans = 0, 1

for i in op:
    if i == 'L':
        ct_L += 1
    else:
        ans *= ct_L
        ct_L -= 1
    ans %= mod


print(factorial(N) * ans % mod)
### BUGGY CODE ###

S = input()
T = input()

from functools import lru_cache
import sys
sys.setrecursionlimit(2147483647)

@lru_cache(None)
def dfs(i,j):
    if i > len(S) - 1 or j > len(T) - 1:
        return ""
    if S[i] == T[j]:
        return S[i] + dfs(i + 1,j + 1)
    else:
        res1 = dfs(i + 1,j)
        res2 = dfs(i, j + 1)
        if max([len(res1),len(res2)]) == len(res1):
            return res1
        else:
            return res2
    
print(dfs(0,0))

### FIXED CODE ###

S = input()
T = input()
dp = [[ 0] * (len(S) + 1 ) for _ in range(len(T) + 1)]
ma = 0
for i in range(len(dp)-1):
    for j in range(len(dp[0])-1):
        if T[i ] == S[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
             dp[i + 1][j + 1]  = max(dp[i][j + 1],dp[i +1][j])
i = len(T) - 1
j = len(S) - 1 
ans = ""
while i >=0 and j >= 0:
    if dp[i][j+1] == dp[i + 1][j + 1]:
        i-=1
    elif dp[i + 1][j] == dp[i + 1][j + 1]:
        j-=1
    else:
        #print(j,i)
        ans = S[j] + ans
        i-=1
        j-=1
print(ans)
### BUGGY CODE ###

#import re

i = int(input().split()[1])
s = input()
k = 0
f = []
e = []
result = []

for k in range(i):
    ff, ee = map(int, input().split())
    f.append(ff)
    e.append(ee)
    #result.append(s[ft - 1:et].count("AC"))
    #result.append(len(re.findall("AC", s[ft - 1:et])))

for k in range(i):
    print(s[f[k] - 1:e[k]].count("AC"))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n, q = map(int, input().split())
s = input()

count = [0]
for i in range(1, n):
    count.append(count[i-1])
    if(s[i-1:i+1] == "AC"):
        count[i] += 1

# print(count)

for _ in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])
### BUGGY CODE ###

K,S = map(int,input().split())
flag = 1
s = 0
for l in range(K+1):
  if l == S+1:
    break
  for m in range(K+1):
    if l == S+1:
      break
    for n in range(K+1):
      if l == S+1:
        break
      if l+m+n == S:
        s = s+1
print(s)

### FIXED CODE ###

K,S = map(int,input().split())
flag = 1
s = 0
for l in range(K+1):
  for m in range(K+1):
    if (0 <= S-l-m)and(S-l-m<=K):
      s = s+1
print(s)
### BUGGY CODE ###

s=list(input())
c = 0
for l in range(len(s)-1, 0, -1):
  for i in range(l):
    if s[i] < s[i+1]:
      s[i], s[i+1] = s[i+1], s[i]
      c += 1
print(c)

### FIXED CODE ###

s=input()
r=w=0
for c,i in zip(s,range(len(s))):
	if c=='W':
		r+=i-w
		w+=1
print(r)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import copy
from operator import itemgetter

[N, M] = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
BC = []
for m in range(M):
    BC.append([int(i) for i in input().split()])

# Aをソートする
A.sort()

# BCをCが大きい順にソートする
sorted_BC = sorted(BC, key=itemgetter(1), reverse=True)
#sorted_BC = sorted(BC, key=lambda x:(x[1]), reverse=True)

for m in range(M):
    [B, C] = sorted_BC[m]
    # もしAの最小値がCを超えていたらもうやる意味ないので終了
    if A[0] > C:
        break

    # 小さいほうからB枚のカードをCに変える
    # ただし変えるのは元の数字より大きい時だけ
    for i in range(B):
        if A[i] < C:
            A[i] = C
    A.sort()


print (sum(A))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import copy
from operator import itemgetter

[N, M] = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
BC = []
for m in range(M):
    BC.append([int(i) for i in input().split()])

# Aをソートする
A.sort()

# BCをCが大きい順にソートする
sorted_BC = sorted(BC, key=itemgetter(1, 0), reverse=True)

new_A = []
for [B, C] in sorted_BC:
    # もしAの最小値がCを超えていたらもうやる意味ないので終了
    if A[0] > C:
        break

    # 小さいほうからB枚のカードをCに変える
    # ただし変えるのは元の数字より大きい時だけ
    I = 0
    for i in range(B):
        I = i
        if len(A) <= i:
            I -=1
            break
        if A[i] > C:
            I -=1
            break
        new_A.append(C)
        #print(new_A)

    # 変えた分はリストから除外する
    #print(A)
    #print(I)
    del A[:I+1]
    if len(A) == 0:
        break

    #print(A)

if len(A) != 0:
    new_A.extend(A)

print (sum(new_A))
### BUGGY CODE ###

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

dp = [0]*(N+3)
dp[0] = 1

for i in range(N+1):
    dp[i] = dp[i] % (10**9 + 7)
    if not i+1 in A:
        dp[i+1] += dp[i]
    if not i+2 in A:
        dp[i+2] += dp[i]
print(dp[N])


### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
A = deque()
[A.append(int(input())) for _ in range(M)]

dp = [0]*(N+3)
dp[0] = 1

for i in range(N+1):
    if A:
        a = A[0]
    else:
        a = 0
    if len(A) >= 2:
        b = A[1]
    else:
        b = 0

    dp[i] = dp[i] % (10**9 + 7)
    if not i+1 == a:
        dp[i+1] += dp[i]
    else:
        A.popleft()
    if not i+2 == b and not i+2 == a:
        dp[i+2] += dp[i]
print(dp[N])
### BUGGY CODE ###

def main():
    n, k, q = map(int, input().split(" "))
    a = (int(input()) for i in range(q))
    d = dict(zip((range(n)), [k]*n))

    for i in a:
        for key in d.keys():
            if (i-1) != key:
                d[key] -= 1

    for value in d.values():
        print("Yes" if value > 0 else "No")
        
main()

### FIXED CODE ###

from collections import defaultdict

def main():
    n, k, q = map(int, input().split(" "))
    a = (int(input()) for i in range(q))
    d = defaultdict(lambda:k-q)
    for i in range(n):
        d[i]

    for i in a:
        d[i-1] += 1

    for value in d.values():
        print("Yes" if value > 0 else "No")


main()
### BUGGY CODE ###

n = int(input())
a = [list(input()) for _ in range(n)]
ans = 0
for s in range(n):
  f = 1
  for i in range(n):
    if not f:
      break
    for j in range(n):
      if a[(i+s)%n][j] != a[(j+s)%n][i]:
        f = 0
        break
  if f:
    ans += n
print(ans)

### FIXED CODE ###

n = int(input())
a = [list(input()) for _ in range(n)]
ans = 0
for s in range(n):
  f = 1
  for i in range(n):
    if not f:
      break
    for j in range(n):
      if a[(i+s)%n][j] != a[(j+s)%n][i]:
        f = 0
        break
  if f:
    ans += n
print(ans)
### BUGGY CODE ###

import numpy as np

def calculate(h, w, arr):
    L = np.zeros([h, w])
    U = np.zeros([h, w])
    D = np.zeros([h, w])
    R = np.zeros([h, w])

    for ih in range(h):
        for iw in range(w):
            if arr[ih][iw] == ".":
                if ih == 0:
                    U[ih][iw] = 1
                if iw == 0:
                    L[ih][iw] = 1

                if iw > 0:
                    L[ih][iw] = L[ih][iw - 1] + 1
                if ih > 0:
                    U[ih][iw] = U[ih - 1][iw] + 1


    for ih in range(h):
        for iw in range(w):
            rih = h - 1 - ih
            riw = w - 1 - iw
            if arr[rih][riw] == ".":
                if rih == h - 1:
                    D[rih][riw] = 1
                if riw == w - 1:
                    R[rih][riw] = 1

                if riw < w - 1:
                    R[rih][riw] = R[rih][riw + 1] + 1
                if rih < h - 1:
                    D[rih][riw] = D[rih + 1][riw] + 1

    max = 0
    for ih in range(h):
        for iw in range(w):
            if arr[ih][iw] == "#":
                continue
            value = L[ih][iw] + R[ih][iw] + U[ih][iw] + D[ih][iw] - 3
            if value > max:
                max = value
    print(int(max))


S = input().split(" ")
H = int(S[0])
W = int(S[1])

arr = []
for i in range(H):
    q = list(input())
    arr.append(q)

calculate(H, W, arr)


### FIXED CODE ###

def calculate(h, w, arr):
    L = [[0]*w for i in range(h)]
    U = [[0]*w for i in range(h)]
    D = [[0]*w for i in range(h)]
    R = [[0]*w for i in range(h)]

    for ih in range(h):
        for iw in range(w):
            if ih == 0:
                U[ih][iw] = 1
            if iw == 0:
                L[ih][iw] = 1

            if arr[ih][iw] == 1:
                L[ih][iw] = 0
                U[ih][iw] = 0

            else:
                if iw > 0:
                    L[ih][iw] = L[ih][iw - 1] + 1
                if ih > 0:
                    U[ih][iw] = U[ih - 1][iw] + 1

            rih = h - 1 - ih
            riw = w - 1 - iw

            if rih == h - 1:
                D[rih][riw] = 1
            if riw == w - 1:
                R[rih][riw] = 1

            if arr[rih][riw] == 1:
                D[rih][riw] = 0
                R[rih][riw] = 0
            else:
                if riw < w - 1:
                    R[rih][riw] = R[rih][riw + 1] + 1
                if rih < h - 1:
                    D[rih][riw] = D[rih + 1][riw] + 1

    max = 0
    for ih in range(h):
        for iw in range(w):
            value = L[ih][iw] + R[ih][iw] + U[ih][iw] + D[ih][iw] - 3
            if value > max:
                max = value
    print(int(max))


S = input().split(" ")
H = int(S[0])
W = int(S[1])

arr = []
for i in range(H):
    q = input()
    tmp = []
    for qs in q:
        if qs == "#":
            tmp.append(1)
        if qs == ".":
            tmp.append(0)
    arr.append(tmp)

calculate(H, W, arr)
### BUGGY CODE ###

from sys import stdin

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

def lcm(a, b):
    return (a * b) // gcd(a, b)

readline = stdin.readline
num = int(readline())
d = list(map(int, readline().split()))
k = 1
MOD = 1000000007
ans = 0
for a in d:
    k = lcm(k, a)
for a in d:
    ans += k // a % MOD
print(ans % MOD)

### FIXED CODE ###

from sys import stdin

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

def lcm(a, b):
    return (a * b) // gcd(a, b)

readline = stdin.readline
num = int(readline())
d = list(map(int, readline().split()))
k = 1
MOD = 1000000007
ans = 0
for a in d:
    k = lcm(k, a)
for a in d:
    ans += k // a
print(ans % MOD)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 9)

# Nがノードの数, Qが操作回数
N, Q = map(int, input().split())

points = [0] * N
nodes = [set() for _ in range(N)]
parents = [-1] * N

for _ in range(N - 1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  nodes[a].add(b)
  nodes[b].add(a)

def fill_parent(parent, n):
  global parents, nodes
  parents[n] = parent
  if parent in nodes[n] and len(nodes[n]) == 1:
    return
  for i in nodes[n]:
    if i != parent:
      fill_parent(n, i)

for i in nodes[0]:
  fill_parent(0, i)

h = {}
for i in range(N):
  if parents[i] not in h:
    h[parents[i]] = set()
  h[parents[i]].add(i)

# print(h)
for _ in range(Q):
  p, x = map(int, input().split())
  p -= 1
  points[p] += x

c = [0] * N

def calc(n):
  if n == 0:
    c[n] = points[n]
  else:
    c[n] = points[n] + c[parents[n]]
  if n in h:
    for i in h[n]:
      calc(i)

calc(0)
print(*c)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 9)

def main():
  input = sys.stdin.buffer.readline
  read = sys.stdin.buffer.read
  # Nがノードの数, Qが操作回数
  N, Q = map(int, input().split())
  ABPX = list(map(int, read().split()))
  AB = iter(ABPX[:N+N-2])
  PX = iter(ABPX[N+N-2:])

  parents = [None] * N
  childrens = [set() for _ in range(N)]
  relations = [[] for _ in range(N)]
  shown = set()

  for a, b in zip(AB, AB):
    a -= 1
    b -= 1
    relations[a].append(b)
    relations[b].append(a)

  points = [0] * N
  result = [0] * N

  for p, x in zip(PX, PX):
    p -= 1
    points[p] += x

  def solve(parent, relations, points, result):
    result[parent] += points[parent]
    shown.add(parent)
    for child in relations[parent]:
      if child not in shown:
        result[child] += result[parent]
        solve(child, relations, points, result)
      
  solve(0, relations, points, result)
  print(*result)

if __name__ == "__main__":
  main()
### BUGGY CODE ###

N, M = list(map(int, input().split()))
gate = [0 for i in range(N+1)]

for i in range(M):
    r, m = list(map(int, input().split()))
    for j in range(r, m+1):
        gate[j] += 1

print(sum([1 for i in gate if i == M]))

### FIXED CODE ###

N, M = list(map(int, input().split()))
l = 1
r = N

for i in range(M):
    L, R = list(map(int, input().split()))
    l = max(l, L)
    r = min(r, R)

print(max(0, r-l+1))
### BUGGY CODE ###

from sys import stdin


class DisjointSet():
    def __init__(self):
        self.parent = None


def ancestor(elems, x):
    s = elems[x]
    while s.parent is not None:
        s = s.parent
    return s


def unite(elems, x, y):
    ax = ancestor(elems, x)
    ay = ancestor(elems, y)
    if ax is not ay:
        parent = DisjointSet()
        ax.parent = ay.parent = parent


def same(elems, x, y):
    return ancestor(elems, x) is ancestor(elems, y)


def main():
    n, q = [int(x) for x in stdin.readline().split()]
    elems = [DisjointSet() for _ in range(n)]

    for _ in range(q):
        com, x, y = [int(x) for x in stdin.readline().split()]
        if com == 0:
            unite(elems, x, y)
        else:
            print(1 if same(elems, x, y) else 0)


if __name__ == '__main__':
    main()



### FIXED CODE ###

class DisjointSetElement():
    def __init__(self, x):
        self.parent = x
        self.rank = 0


class DisjointSet():
    def __init__(self, n):
        self.elems = [DisjointSetElement(n) for n in range(n)]

    def _find_set(self, x):
        if x != self.elems[x].parent:
            self.elems[x].parent = self._find_set(self.elems[x].parent)
        return self.elems[x].parent

    def same(self, x, y):
        return self._find_set(x) == self._find_set(y)

    def _link(self, x, y):
        if self.elems[x].rank > self.elems[y].rank:
            self.elems[y].parent = x
        else:
            self.elems[x].parent = y
            if self.elems[x].rank == self.elems[y].rank:
                self.elems[y].rank += 1

    def unite(self, x, y):
        self._link(self._find_set(x), self._find_set(y))


def main():
    n, q = [int(x) for x in input().split()]
    ds = DisjointSet(n)

    for _ in range(q):
        com, x, y = [int(x) for x in input().split()]
        if com == 0:
            ds.unite(x, y)
        else:
            print(1 if ds.same(x, y) else 0)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

C=[input().split() for i in range(N)]
B=[]
for i in C:
    B.append(list(map(int,i)))

B.sort()

k=0
l=0#何番目の店
m=0#その店で買う数
money=0
X=0#持ち数

while M>X:
    Min=B[0][0]
    for i in B:#どの店で買うか
        if Min>=i[0]:
            Min=i[0]
            l=k
        k+=1

    for x in range(B[l][1]):#何個かえるか

        m+=1
        if M==X+m:#max
            money+=m*Min
            print(money)
            break


    money+=m*Min
    X+=m

    B.pop(l)#取り出す
    #リセット
    k=0
    l=0
    m=0#その店で買う数


### FIXED CODE ###

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

C=[input().split() for i in range(N)]
B=[]
for i in C:
    B.append(list(map(int,i)))

B.sort()

k=0
l=0#何番目の店
m=0#その店で買う数
money=0
X=0#持ち数
for a,b in B:
    if(M<=0):
        break
    if(b<=M):
        money+=a*b
    else:
        money+=M*a
    M-=b
print(money)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
E=[list(map(int,input().split())) for i in range(M)]
S,G=map(int,input().split())

ELIST=[set() for i in range(N+1)]

for x,y in E:
    ELIST[x].add(y)

check=[float("inf")]*(N+1)
check[S]=0

def three_step_from(S,i):

    ONE=set()

    for s in S:

        ONE=ONE|ELIST[s]

    TWO=set()
    for one in ONE:
        
        TWO=TWO|ELIST[one]

    THREE=set()
    for two in TWO:
        THREE=THREE|ELIST[two]

    RET=set()

    for three in THREE:
        if check[three]!=float("inf"):
            continue
        check[three]=i
        RET.add(three)

    return RET

i=1
NOW={S}
while NOW:
    NOW=three_step_from(NOW,i)
    i+=1

if check[G]==float("inf"):
    print(-1)
else:
    print(check[G])
    
        


### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
E=[list(map(int,input().split())) for i in range(M)]
S,G=map(int,input().split())

ELIST=[[] for i in range(N+1)]

for x,y in E:
    ELIST[x].append(y)

DIS=[[-1,-1,-1] for i in range(N+1)]
DIS[S][0]=0

from collections import deque

S=deque([S])
i=1

while S:
    #print(S)
    NEWS=deque()
    while S:     
        x=S.pop()

        for to in ELIST[x]:
            if DIS[to][i%3]==-1:
                DIS[to][i%3]=i
                NEWS.append(to)

    i+=1
    S=NEWS

print(DIS[G][0]//3)
### BUGGY CODE ###

x = input()
le = len(x)
while True:
    bit = 0
    for i in range(le-1):
        if x[i:i+2] == "ST":
            x = x[0:i]+x[i+2:le]
            bit = 1
            break
    if bit == 0:
        print(len(x))
        break

### FIXED CODE ###

import numpy as np
import functools
import math
import scipy
import fractions
import itertools
 
def solve():
    x = input()
    a, b = 0, 0
    for i in x:
        if i == "S":
            a += 1
        else:
            if a == 0:
                b += 1
            else:
                a -= 1
    print(a + b)
    return 0

if __name__ == "__main__":
    solve()