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

import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**9)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

x = INT()
flag = [False]

def dfs(cur):
    if cur==x:
        flag[0] = True
        return 0
    if cur>x:
        return 1
    
    if dfs(cur+100)==0:
        return 0
    if dfs(cur+101)==0:
        return 0
    if dfs(cur+102)==0:
        return 0
    if dfs(cur+103)==0:
        return 0
    if dfs(cur+104)==0:
        return 0
    if dfs(cur+105)==0:
        return 0

dfs(0)
if flag[0]:
    print(1)
else:
    print(0)

### FIXED CODE ###

import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**9)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

x = INT()

for i in range(1,10**6+1):
    if i*100<=x<=i*105:
        print(1)
        exit()
print(0)
### BUGGY CODE ###

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

l = [set() for i in range(N)]

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

par = [-1] * N
par[0] = 0

stack = [0]
while stack:
  prev = stack.pop()
  for to in l[prev]:
    if par[to] < 0:
      par[to] = prev
      stack.append(to)

counter = [0] * N

for i in range(Q):
  p, x = map(int, input().split())
  counter[p-1] += x

r = [-1] * N
r[0] = counter[0]

for i in range(N):
  s = 0
  cur = i
  while r[cur] < 0:
    s += counter[cur]
    cur = par[cur]
  r[i] = r[cur] + s

print(*r)

### FIXED CODE ###

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

l = [[] for i in range(N)]

for i in range(N-1):
  a, b = map(int, input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)

used = [False] * N
r = [0] * N

for i in range(Q):
  p, x = map(int, input().split())
  r[p-1] += x

stack = [0]
while stack:
  i = stack.pop()
  used[i] = True
  for to in l[i]:
    if not used[to]:
      stack.append(to)
      r[to] += r[i]

print(*r)
### BUGGY CODE ###

N = int(input())
C = [int(input()) for _ in range(N)]
   
i=0 
while i+1<len(C):
    if C[i]==C[i+1]:
        C.pop(i+1)
    else:
        i+=1

DP = [1]
dic = {}      

for i in range(len(C)):  
    if not(C[i] in dic):
        DP.append(DP[-1])
    else:
        DP.append((DP[-1]+DP[dic[C[i]]])%(10**9+7))
    dic[C[i]] = i+1            
print(DP[-1])


### FIXED CODE ###

N = int(input())
C = [int(input()) for _ in range(N)]
C = [x for x,y in zip(C[:-1],C[1:]) if x!=y] + [C[-1]]

DP = [1]
dic = {}

for i in range(len(C)):   
    DP.append((DP[-1]+dic.get(C[i],0))%(10**9+7))    
    dic[C[i]] = DP[-1]
print(DP[-1])
### BUGGY CODE ###

k,s = map(int, input().split())
a = []
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            a.append(i+j+l)
b = a.count(s)
print(b)

### FIXED CODE ###

k,s = map(int, input().split())
a = 0
for i in range(min(s+1, k+1)):
    for j in range(min(s - i + 1, s+1, k+1)):
        if s - i - j <= k:
            a += 1
print(a)
### BUGGY CODE ###

import fractions
from functools import reduce

def gcd(*numbers):
  return reduce(fractions.gcd, numbers)

K = int(input())
total = 0

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      total += gcd(a,b,c)
print(total)

### FIXED CODE ###

import math
ans = 0
n = int(input())

for i in range(1,n+1):
    for j in range(1,n+1):
        l = math.gcd(i,j)
        for k in range(1,n+1):
            ans += math.gcd(k,l)
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
l=sorted([list(map(int,input().split())) for _ in [0]*n],key=lambda x:[x[0],-x[1]])+[[float('inf'),float('inf')]]
for i in range(n):l[i][0]-=1
w=[0]*m
for i in range(m):
    j=0
    k=-1
    while l[j][0]<=i:
        if l[j][1]>w[i]:
            w[i]=l[j][1]
            k=j
        j+=1
    if k>=0:del l[k]
print(sum(w))

### FIXED CODE ###

from heapq import heappop, heappush

n,m=map(int,input().split())
a=[]
for i in range(n):
    heappush(a,list(map(int,input().split())))
heap=[]
s=0
for i in range(m):
    while 1:
        if len(a)==0:break
        else:
            if a[0][0]==i+1:heappush(heap,-heappop(a)[1])
            else:break
    if len(heap)>0:s+=-heappop(heap)
print(s)
### BUGGY CODE ###

import fractions
from functools import reduce

N = int(input())
A = [int(i) for i in input().split(" ")]

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

ans = 1
for i in range(N):
    cand = gcd_list(A[:i] + A[i+1:])
    if cand > ans:
        ans = cand
print(ans)

### FIXED CODE ###

from fractions import gcd

N = int(input())
A = [int(i) for i in input().split(" ")]

if N == 2:
    print(max(A))
    import sys
    sys.exit()

g = gcd(A[0], A[1])
lmax = 1
num = 0
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
A = A[1:] + [A[0]]
g = gcd(A[0], A[1])
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
A = A[1:] + [A[0]]
g = gcd(A[0], A[1])
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
if num == A[0]:
    A = A[1:]
    flag = False
    N -= 1
elif num == A[1]:
    A = [A[0]] + A[2:]
    flag = False
    N -= 1
else:
    flag = True
g = gcd(A[0], A[1])
for i in range(2,N):
    if A[i] == num and flag:
        flag = False
    else:
        g = gcd(g, A[i])
print(g)
### BUGGY CODE ###

a,b,x = map(int,input().split())
ans = 0
for i in range(b-a+1):
    if (a+i)%x==0:
        ans += 1
print(ans)

### FIXED CODE ###

a,b,x = map(int,input().split())
ans = 0
if a%x==0:
    ans = (b-a)//x+1
else:
    c = (a//x+1)*x
    ans = (b-c)//x+1
print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
result=1
for i in a:
    result*=i
if pow(10,18)<result:
    print(-1)
else:
    print(result)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
result=1
for i in a:
    result*=i
    if 10**18<result:
        result=-1
        break
print(result)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
N = int(input())
A = []
A  = list(map(int,input().split()))	
from operator import add, mul, sub,truediv, floordiv
from functools import reduce

i = reduce(lambda x, y: x*y,A)
if i > 1000000000000000000:
    print("-1")
else:
    print(i)
    

### FIXED CODE ###

N = int(input())
A = []
A  = list(map(int,input().split()))	
if A.count(0)!=0:
    print("0")
    exit()
ans = 1
for i in A:
    ans = ans*i
    if ans > 1000000000000000000:
        print("-1")
        exit()
print(ans)
### BUGGY CODE ###

n = int(input())
R = [0 for _ in range(n)]
for i in range(n):
    R[i] = int(input())

m = -float('inf')
for i in range(n-1):
    for j in range(i+1, n):
        if R[j]-R[i] > m:
            m = R[j]-R[i]

print(m)

### FIXED CODE ###

import sys

n = int(input())
r0 = int(input())
r1 = int(input())
p = r1 - r0
r = min(r0,r1)
for i in map(int, sys.stdin.readlines()):
    if p < i - r:
        p = i - r
    if r > i:
        r = i

print(p)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().rstrip().split())
checked = [[-1]*W for i in range(H)]

queue = deque([])

# 初期化
# 0 => 黒、 -1 => 白
for i in range(H):
    row = input().rstrip()
    for j in range(W):
        if row[j] == "#":
            checked[i][j] = 0
            queue.append((i, j))


directions = [(0, 1), (0, -1), (1, 0), (-1, 0)]
# 黒の周辺4方向のうち、白だったら黒にする
while queue:
    x, y = queue.popleft()

    # 周囲探索
    for dx, dy in directions:
        xx = x + dx
        yy = y + dy

        if xx >= 0 and xx < H and yy >= 0 and yy < W:
            if checked[xx][yy] == -1:
                checked[xx][yy] = checked[x][y] + 1
                queue.append((xx, yy))

ans = 0
for i in range(H):
    for j in range(W):
        if ans < checked[i][j]:
            ans = checked[i][j]
print(ans)


### FIXED CODE ###

H, W = map(int, input().rstrip().split())
checked = [[True]*(W+2)]
checked += [[True] + [ch == "#" for ch in input().rstrip()] + [True]
            for i in range(H)]
checked.append([True]*(W+2))

black_list = []
# 初期化
# 0 => 黒、 -1 => 白
for i in range(1, H+1):
    for j in range(1, W+1):
        if checked[i][j]:
            black_list.append((i, j))

# 黒の周辺4方向のうち、白だったら黒にする
ans = -1
while black_list:
    ans += 1
    tmp = []
    for x, y in black_list:
        # 上
        if not checked[x-1][y]:
            checked[x-1][y] = True
            tmp.append((x-1, y))
        # 下
        if not checked[x+1][y]:
            checked[x+1][y] = True
            tmp.append((x+1, y))
        # 左
        if not checked[x][y-1]:
            checked[x][y-1] = True
            tmp.append((x, y-1))

        # 右
        if not checked[x][y+1]:
            checked[x][y+1] = True
            tmp.append((x, y+1))

    black_list = tmp

print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())
XY = [[set() for i in range(10**5+1)] for j in range(2)]
for i in range(N):
  x, y = map(int, input().split())
  XY[0][x].add(y)
  XY[1][y].add(x)

is_visited_x = [False] * (10**5 + 1)
def dfs(x):
  global is_visited_x
  is_visited_x[x] = True
  stack = [[x], []]
  idx = 0
  num_e = 0
  num_xy = [1, 0]
  parent = 0
  while stack[0] or stack[1]:
    node = stack[idx][-1]
    children = XY[idx][node]
    if children:
      child = children.pop()
      XY[idx-1][child].remove(node) # 今来た道を削除
      num_e += 1
      if child in stack[idx-1]:
        continue
      stack[idx-1].append(child)
      num_xy[idx-1] += 1
      is_visited_x[child] += idx
      idx = (idx + 1) % 2
    else:
      stack[idx].pop()
      idx = (idx + 1) % 2
  return num_e, num_xy

ans = 0
for x in range(1, 10**5+1):
  if is_visited_x[x]:
    continue
  num_e, num_xy = dfs(x)
  ans += num_xy[0]*num_xy[1] - num_e

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
XY = [[set() for i in range(10**5+1)] for j in range(2)]
for i in range(N):
  x, y = map(int, input().split())
  XY[0][x].add(y)
  XY[1][y].add(x)

is_visited_x = [False] * (10**5 + 1)
def dfs(x):
  global is_visited_x
  is_visited_x[x] = True
  stack = [[x], []]
  idx = 0
  num_e = 0
  num_xy = [1, 0]
  parent = 0
  while stack[0] or stack[1]:
    node = stack[idx][-1]
    children = XY[idx][node]
    if children:
      child = children.pop()
      XY[idx-1][child].remove(node) # 今来た道を削除
      num_e += 1
      if child in stack[idx-1]:
        continue
      stack[idx-1].append(child)
      num_xy[idx-1] += 1
      is_visited_x[child] += idx
      idx = (idx + 1) % 2
    else:
      stack[idx].pop()
      idx = (idx + 1) % 2
  return num_e, num_xy

ans = 0
for x in range(1, 10**5+1):
  if is_visited_x[x]:
    continue
  num_e, num_xy = dfs(x)
  ans += num_xy[0]*num_xy[1] - num_e

print(ans)
### BUGGY CODE ###

# import queue
# from collections import deque

h, w = map(int, input().split())

grid = [[True] * (w + 2)]
for _ in range(h):
    grid.append([True] + [x == '#' for x in input()] + [True])
grid.append([True] * (w + 2))

# q = deque()
q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if grid[i][j] is True:
            q.append((i, j))

cnt = 0
while True:
    qq = []
    for (i, j) in q:
        # i, j = q.pop()
        if grid[i + 1][j] is False:
            grid[i + 1][j] = True
            qq.append((i + 1, j))
        if grid[i - 1][j] is False:
            grid[i - 1][j] = True
            qq.append((i - 1, j))
        if grid[i][j + 1] is False:
            grid[i][j + 1] = True
            qq.append((i, j + 1))
        if grid[i][j - 1] is False:
            grid[i][j - 1] = True
            qq.append((i, j - 1))

    if not qq:
        break
    cnt += 1
    q = qq

print(cnt)


### FIXED CODE ###

h, w = map(int, input().split())

grid = [[True] * (w + 2)]
for _ in range(h):
    grid.append([True] + [x == '#' for x in input()] + [True])
grid.append([True] * (w + 2))

q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if grid[i][j] is True:
            q.append((i, j))

cnt = 0
while q:
    qq = []
    for i, j in q:
        if not grid[i + 1][j]:
            grid[i + 1][j] = True
            qq.append((i + 1, j))
        if not grid[i - 1][j]:
            grid[i - 1][j] = True
            qq.append((i - 1, j))
        if not grid[i][j + 1]:
            grid[i][j + 1] = True
            qq.append((i, j + 1))
        if not grid[i][j - 1]:
            grid[i][j - 1] = True
            qq.append((i, j - 1))

    cnt += 1
    q = qq

print(cnt - 1)
### BUGGY CODE ###

n=input()
num_list=[]
for i in range(n):
    m=input()
    num_list.append(m)

Max=num_list[1]-num_list[0]

for i in range(n-1):
    for j in range(i+1,n):
        if Max<num_list[j]-num_list[i]:
            Max=num_list[j]-num_list[i]

print(Max)

### FIXED CODE ###

n=input()
for i in range(n):
	if i==0:
		num_1=input()
	elif i==1:
		num_2=input()
		maxv=num_2 - num_1
		MIN=min(num_1,num_2)
	else:
		num_3=input()
		if (num_3-MIN)>maxv:
			maxv=num_3-MIN
		if (num_3)<MIN:
			MIN=num_3
print(maxv)
### BUGGY CODE ###

import numpy as np


n = int(input())
a = np.array(list(map(int, input().split())))
# E = 0.5 * (np.eye(n) + np.eye(n, n, 1) + np.eye(n, n, -n + 1))
vec = (-1) ** np.arange(n)
print(' '.join([str(int(np.dot(np.roll(vec, i), a))) for i in range(n)]))

### FIXED CODE ###

import numpy as np


n = int(input())
a = np.array(list(map(int, input().split())))
# E = 0.5 * (np.eye(n) + np.eye(n, n, 1) + np.eye(n, n, -n + 1))
vec = (-1) ** np.arange(n)
b = np.zeros(n)
b[0] = np.dot(vec, a)
b[1] = np.dot(np.roll(vec, 1), a)
for i in range(2, n):
    sgn = (-1) ** (i % 2)
    b[i] = b[i - 2] - 2 * (a[i - 2] - a[i - 1])
print(' '.join([str(int(i)) for i in b]))
### BUGGY CODE ###

# -*- coding: utf-8 -*-


s = input().splitlines()[0]
t = input()


Slen = len(s)
Index = -1
Loop = 0
LUT = [[] for i in range(26)]
for i, c in enumerate(s):
    v = ord(c) - ord('a')
    LUT[v].append(i)

NotFound = False
for c in t:
    v = ord(c) - ord('a')
    if len(LUT[v]) == 0:
        NotFound = True
        break
    m = -1
    for l in LUT[v]:
        if l > Index:
            m = l
            break
    if m < 0:
        Index = LUT[v][0]
        Loop += 1
    else:
        Index = m

if NotFound:
    print(-1)
else:
    print(Loop*Slen+Index+1)


### FIXED CODE ###

# -*- coding: utf-8 -*-


def main():
    s = input().splitlines()[0]
    t = input().splitlines()[0]

    Slen = len(s)

    LookupTable = [[] for i in range(26)]
    for i, c in enumerate(s):
        v = ord(c) - ord('a')
        LookupTable[v].append(i)
    for i in range(26):
        LookupTable[i].append(-1)
        
    IndexTable = [0 for i in range(26)]
    NextTable = []
    for i, c in enumerate(s):
        v = ord(c) - ord('a')
        NextTable.append( [LookupTable[k][IndexTable[k]] for k in range(26)] )
        IndexTable[v] += 1
        if LookupTable[v][IndexTable[v]] < 0:
            IndexTable[v] = 0

    Index = 0
    Loop = 0
    for i, c in enumerate(t):
        v = ord(c) - ord('a')
        if NextTable[Index][v] < Index:
            Loop += 1
        Index = NextTable[Index][v]
        if Index < 0:
            print(-1)
            return
        Index += 1
        if Index >= Slen:
            Index = 0
            Loop += 1

    print(Loop*Slen+Index)


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

s = input()
q = int(input())
query = []

def func(string, t, f, c):
    if int(t) == 1:
        new_str = ''.join(list(reversed(string)))
        return new_str
    else:
        if int(f) == 1:
            return c + string
        else:
            return string + c

for i in range(0,q):
    query.append(input().split())
for i in query:
    if int(i[0]) == 1:
        s = func(s,i[0],'','')
    else:
        s = func(s,i[0],i[1],i[2])
print(s)


### FIXED CODE ###

s = input()
q = int(input())
query = []
lead = ''
end = ''
inversion_flg = False
 
for j in range(q):
    i = input().split()
    if i[0] == "1":
        if inversion_flg:
            inversion_flg = False 
        else:
            inversion_flg = True
    else:
        if inversion_flg:
            if i[1] == "1":
                i[1] = "2"
            else:
                i[1] = "1"
        if i[1] == "1":
            lead+=i[2]
        else:
            end+=i[2]
 
lead = lead[::-1]
s = lead+s+end
if inversion_flg:
    s = s[::-1]
print(s)
### BUGGY CODE ###

N,X,Y=map(int,input().split())
ans=[]
for i in range(1,N):
    for j in range(i+1,N+1):
        a=j-i
        a=min(a,abs(j-Y)+abs(i-X)+1)
        ans.append(a)
for i in range(1,N):
    Ans=ans.count(i)
    print(Ans)

### FIXED CODE ###

N,X,Y=map(int,input().split())
ans=[]
count=[0]*(N-1)
for i in range(1,N):
    for j in range(i+1,N+1):
        a=j-i
        a=min(a,abs(j-Y)+abs(i-X)+1)
        count[a-1]+=1
for i in range(0,N-1):
    print(count[i])
### BUGGY CODE ###

import math

n=int(input())
 
total=0
for nn in range(1,n+1):
  for k in range(1,n+1):
    for l in range(1,n+1):
      total+=math.gcd(nn,math.gcd(k,l))
 
print(total)

### FIXED CODE ###

import math

n=int(input())
 
def diffs(n):
  total=0
  for k in range(1,n):
    for l in range(k+1,n):
      total+=math.gcd(n,math.gcd(k,l))*6
  for k in range(1,n):
    total+=math.gcd(n,k)*6
  total += n
  return total

sum=0
for i in range(1,n+1):
  sum += diffs(i)

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

import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)
result = []

max_k, mx = max(count.items(), key=lambda x : x[1])

result.append(max_k)
del count[max_k]
for i in range(len(count)):
    max_k, max_v = max(count.items(), key=lambda x : x[1])
    if max_v == mx:
        result.append(max_k)
        del count[max_k]
    else:
        break
print("\n".join(sorted(result)))

### FIXED CODE ###

import collections


N = int(input())

S = [input() for i in range(N)]

count = collections.Counter(S)


mx = max(count.values())

result = [key for key, val in count.items() if val == mx]
print("\n".join(sorted(result)))
### BUGGY CODE ###

def sousa(n,k):
    return abs(n-k)

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

while N > abs(N-K):
    N = abs(N-K)

print(N)

### FIXED CODE ###

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

j = N//K

if N-j*K > -(N-(j+1)*K):
    print(-(N-(j+1)*K))
else:
    print(N-j*K)
### BUGGY CODE ###

n = int(input())
for i in range(1,n+1):
    c = 0
    total = n
    while 1:
        for x in range(1,i//2):
            for y in range(x,i//2):
                for z in range(y,i//2):
                    total = ((x+y)**2 + (z+y)**2 + (x+z)**2) / 2
                    if total == i:
                        if x==y==z:
                            c += 1
                        elif x ==y or y == z:
                            c += 3
                        else:
                            c += 6
                        break
                    elif total>i:
                        break
        if total>i:
            break
    print(c)

### FIXED CODE ###

n = int(input())
a = [0 for i in range(n)]
c = 0
total = n
for x in range(1, n//2):
    for y in range(x, n//2):
        for z in range(y, n//2):
            total = int(((x+y)**2 + (z+y)**2 + (x+z)**2) / 2)
            try:
                if x == y == z:
                    a[total-1] += 1
                elif x == y or y == z:
                    a[total-1] += 3
                else:
                    a[total-1] += 6
            except:
                break
for i in a:
    print(i)
### BUGGY CODE ###

a,b,n=map(int,input().split())
list=[]
for x in range(n+1):
  list.append(int(a*x/b)-a*int(x/b))
print(max(list))

### FIXED CODE ###

a,b,n=map(int,input().split())
if n>=b:
  print(int(a*(b-1)/b)-a*int((b-1)/b))
else:
  print(int(a*n/b)-a*int(n/b))
### BUGGY CODE ###

def main():
    N=input()
    A=list(map(int, input().split()))

    mod_value = 10**9 + 7
    sum = 0
    for i in range(len(A)-1):
        for j in range(i+1,len(A)):
           sum = sum + A[i]*A[j] % mod_value
    print(sum % mod_value)
main()


### FIXED CODE ###

def main():
    N=input()
    A=list(map(int, input().split()))

    mod_value = 10**9 + 7
    sum_ = 0
    b_sum = 0
    for i in range(len(A)-1):
        b_sum = b_sum + A[len(A)-i-1]
        sum_ = sum_ + (A[len(A)- i - 2]*b_sum) % mod_value
    print(sum_%mod_value)
main()
### BUGGY CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

k = 8000
def foo(fe,x,ev):
    n = len(fe)
    d = [ [False]*(2*k+1) for i in range(n+1) ]
    d[0][k] = True
    if len(fe)>0:
        d[1][fe[0]+k] = True
        if not ev:
            d[1][-fe[0]+k] = True
    for i in range(1,n):
        for j in range(-k,k+1):
            if d[i][j+k]:
                d[i+1][j+fe[i]+k] = True
                d[i+1][j-fe[i]+k] = True
    return d[n][x+k]

s = ins()
x,y = inm()
f = [ [], [] ]
strk = 0
turn = 0
n = len(s)
for i in range(n):
    if s[i]=='T':
        f[turn].append(strk)
        turn = 1 - turn
        strk = 0
    else:
        strk += 1
f[turn].append(strk)
if foo(f[0],x,True) and foo(f[1],y,False):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(fe,x,ev):
    k = sum(fe)+1
    n = len(fe)
    d = [ [False]*(2*k+1) for i in range(n+1) ]
    d[0][k] = True
    if len(fe)>0:
        d[1][fe[0]+k] = True
        if not ev:
            d[1][-fe[0]+k] = True
    for i in range(1,n):
        for j in range(-k,k+1):
            if d[i][j+k]:
                d[i+1][j+fe[i]+k] = True
                d[i+1][j-fe[i]+k] = True
    return -k<=x<=k and d[n][x+k]

s = ins()
x,y = inm()
f = [ [], [] ]
strk = 0
turn = 0
n = len(s)
for i in range(n):
    if s[i]=='T':
        f[turn].append(strk)
        turn = 1 - turn
        strk = 0
    else:
        strk += 1
f[turn].append(strk)
if foo(f[0],x,True) and foo(f[1],y,False):
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C = MAP()
    if not (A%2==0 and B%2==0 and C%2==0):
        print(0)
        return

    if A==B==C:
        print(-1)
        return
    answer = 0
    
    while A%2==0 and B%2==0 and C%2==0:
        x = A//2
        y = B//2
        z = C//2
        A = y+z
        B = x+y
        C = y+z
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C = MAP()
    if A==B==C:
        if A%2==1 or B%2==1 or C%2==1:
            print(0)
        else:
            print(-1)
        return
    answer = 0
    
    while A%2==0 and B%2==0 and C%2==0:
        x = A//2
        y = B//2
        z = C//2
        A = y+z
        B = x+z
        C = y+x
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()