Harryxun/stf_run huggingface dataset:
S=list(map(len,input().split("T")))
x,y=map(lambda x:abs(int(x)),input().split())
L=S[::2]
R=S[1::2]
sumL=sum(L)
sumR=sum(R)
flag=0    
if sumL>=x and sumR>=y and (sumL-x)%2==0 and (sumR-y)%2==0 and flag==0:
    setL={0}
    setR={0}
    gL=(sumL-x)//2
    gR=(sumR-y)//2
    if gL==0:
        flag=1
    else:
        for i in L:
            for j in setL:
                k=i+j
                if k<gL:
                    setL.add(k)
                elif k==gL:
                    flag=1
                    break
            if flag==1:
                break
    if flag==1:
        if gR==0:
            flag=2
        else:
            for i in R:
                for j in setR:
                    k=i+j
                    if k<gR:
                        setR.add(k)
                    elif k==gR:
                        flag=2
                        break
                if flag==2:
                    break
if flag==2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from itertools import accumulate
S=list(map(len,input().split("T")))
x,y=map(int,input().split())
x=abs(x-S[0])
y=abs(y)
L=S[2::2]
R=S[1::2]
La=list(accumulate(L))
Ra=list(accumulate(R))
sumL=sum(L)
sumR=sum(R)
flag=0
if sumL>=x and sumR>=y and (sumL-x)%2==0 and (sumR-y)%2==0 and flag==0:
    setL1={0}
    setR1={0}
    gL=(sumL-x)//2
    gR=(sumR-y)//2
    if gL==0:
        flag=1
    else:
        for cnt,i in enumerate(L):
            setL=setL1
            setL1=set()
            s=setL1.add
            h=sumL-La[cnt]
            for j in setL:
                k=i+j
                #if k<gL and h+k>=gL:
                s(k)
                #if j<gL and h+j>=gL:
                s(j)
                if k==gL:
                    flag=1
                    break
            if flag==1:
                break
    if flag==1:
        if gR==0:
            flag=2
        else:
            for cnt,i in enumerate(R):
                setR=setR1
                setR1=set()
                s=setR1.add
                h=sumR-Ra[cnt]
                for j in setR:
                    k=i+j
                    #if k<gR and h+k>=gR:
                    s(k)
                    #if j<gR and h+j>=gR:
                    s(j)
                    if k==gR:
                        flag=2
                        break
                if flag==2:
                    break
if flag==2:
    print("Yes")
else:
    print("No")
N=int(input())
s=list(map(int,input().split()))
if s[0]<0:
    t=1
elif s[0]>0:
    t=-1
ss=s[0]   
w=0
for i in range(N-1):
    if t==1:
        if ss+s[i+1]>=t:
            ss=ss+s[i+1]
            pass
        else:
            w+=t-ss-s[i+1]
            ss=1
        t=-1
    elif t==-1:
        if ss+s[i+1]<=t:
            ss=ss+s[i+1]
            pass
        else:
            w+=ss+s[i+1]-t
            ss=-1
        t=1
print(w)        
                
            
            
            
        
        

### FIXED CODE ###

# coding: utf-8
# hello worldと表示する
N=int(input())
s=list(map(int,input().split()))
def f(N,s,t):
    ss=0
    w=0
    for i in range(N):
        ss+=s[i]
        if t==1:
            if ss<=0:
                w+=1-ss
                ss=1
            t=-1    
        elif t==-1:
            if ss>=0:
                w+=1+ss
                ss=-1
            t=1
    return w
t=1
a=f(N,s,t)
t=-1
b=f(N,s,t)
print(min(a,b))
import numpy as np

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

print(np.max(A-B, A+B, A*B)

### FIXED CODE ###

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

print(max(A-B, A+B, A*B))
N = int(input())

ans = float('inf')
print(0)
s = input()
if s == "Male":
	pre = 1
elif s == "Female":
	pre = 0
else:
	ans = 0

if ans == 0:
	exit(0)

ran = [0,N-1]
for i in range(19):	
	print(ran)
	n = (ran[1] - ran[0]) // 2
	print(ran[0] + n)
	s = input()
	if s == "Male":
		flg = 1
	elif s == "Female":
		flg = 0
	else:
		exit(0)

	if (flg + n%2) != pre:
		ran[1] = ran[0] + n - 1
	else:
		ran[0] = ran[0] + n + 1
		pre = flg

### FIXED CODE ###

N = int(input())
ans = float('inf')
print(0)
s = input()
if s == "Male":
	pre = 1
elif s == "Female":
	pre = 0
else:
	ans = 0

if ans == 0:
	exit(0)

ran = [0,N-1]
for i in range(19):	
	n = (ran[1] - ran[0]) // 2
	print(ran[0] + n)
	s = input()
	if s == "Male":
		flg = 1
	elif s == "Female":
		flg = 0
	else:
		exit(0)

	if (pre + n) % 2 != flg:
		ran[1] = ran[0] + n - 1
	else:
		ran[0] = ran[0] + n + 1
		pre = (flg + 1) % 2
a=sorted([int(input())for _ in[0]*int(input())])[:4]
b=[]
for i in range(3):
 for d in a[i:4]:
  c=a[i]
  b+=[c*10**len(d)+d,d*10**len(c)+c]
print(sorted(b)[2])


### FIXED CODE ###

import itertools
print(sorted(int(f'{a}{b}')for a,b in itertools.permutations(sorted(int(input())for _ in[0]*int(input()))[:4],2))[2])
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math

n = int(input())
a = [int(i) for i in input().split()]
bound = int(math.log2(max(a)) + 1)

k = [0] * bound

for i in a:
    for j in range(bound):
        if (i >> j) & 1:
            k[j] += 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

n = int(input())
a = np.array([int(i) for i in input().split()])

k = [0] * 60

for j in range(60):
    l = a & 1
    k[j] = np.count_nonzero(l)
    a >>= 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))
def f(x):
    if x == 0:
        return 1
    elif x == 1:
        return 0

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

a = [[0]*(M+2) for _ in range(N+2)]
for i in range(N):
    for j in range(M):
        for k in range(3):
            for l in range(3):
                a[i+k][j+l] = f(a[i+k][j+l])
print(sum(a[1:N+1, 1:M+1]))


### FIXED CODE ###

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

if N==1 and M==1:
    print(1)
elif N==1:
    print(M-2)
elif M==1:
    print(N-2)
elif N==2 or M==2:
    print(0)
else:
    print((N-2)*(M-2))
N = int(input())
A = list(map(int,input().split(",")))
tmp = 0
A.sorted()
for i in range(N):
  tmp = tmp + 1/A[i]
  
print(1/tmp)

### FIXED CODE ###

N = int(input())
A = list(map(float,input().split()))
tmp = 0
for i in range(N):
  tmp = tmp + (1/A[i])
tmp= 1/tmp
print(tmp)
from operator import mul
from functools import reduce

def nCr(n, r):
    r = min(n-r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

def read():
    N, K = list(map(int, input().strip().split()))
    return N, K

def solve(N, K):
    for i in range(1, K + 1):
        count = nCr(N - K + 1, i) * nCr(K - 1, i - 1)
        print(count % (10**9 + 7))

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


### FIXED CODE ###

from operator import mul
from functools import reduce

def nCr(n, r):
    r = min(n-r, r)
    if r == 0: return 1
    if r < 0: return 0
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

def read():
    N, K = list(map(int, input().strip().split()))
    return N, K

def solve(N, K):
    for i in range(1, K + 1):
        count = nCr(N - K + 1, i) * nCr(K - 1, i - 1)
        print(count % (10**9 + 7))

if __name__ == '__main__':
    inputs = read()
    solve(*inputs)
a = input()
b = list(int(input()))
x = max(b)-max(b)
print(x)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
print(abs(A[0]-A[-1]))
# coding: utf-8
# Your code here!

import math

def lcm(x,y):
    return (x * y) // math.gcd(x,y)

a = list(map(int,input().split()))
ans = lcm(a[0], a[1])
print(ans)

### FIXED CODE ###

import sys
import fractions

def lcm(x,y):
    return (x * y) // fractions.gcd(x,y)

a = list(map(int,input().split()))
ans = lcm(a[0], a[1])

print(ans)
import bisect
S = input()
T = input()
OUT = 10**5

N = len(S)
M = len(T)
indice = [0]*M
# 素直にやるとO(NM)かかるので工夫が必要
A = [[] for _ in range(26)]
for i in range(N):
    A[ord(S[i]) - ord('a')].append(i + 1)

res = 0
b = 0
for j in range(M):
    tj = ord(T[j]) - ord('a')
    if len(A[tj]) == 0:
        print(-1)
        exit()
    r = bisect.bisect_right(A[tj], b)
    if len(A[tj]) > r:
        res += A[tj][r] - b
        b = A{tj}[r]
    else:
        res += N - b + A[tj][0]
        b = A[tj][0]

print(res)

### FIXED CODE ###

import bisect
S = input()
T = input()
OUT = 10**5

N = len(S)
M = len(T)
indice = [0]*M
# 素直にやるとO(NM)かかるので工夫が必要
A = [[] for _ in range(26)]
for i in range(N):
    A[ord(S[i]) - ord('a')].append(i + 1)

res = 0
b = 0
for j in range(M):
    tj = ord(T[j]) - ord('a')
    if len(A[tj]) == 0:
        print(-1)
        exit()
    r = bisect.bisect_right(A[tj], b)
    if len(A[tj]) > r:
        res += A[tj][r] - b
        b = A[tj][r]
    else:
        res += N - b + A[tj][0]
        b = A[tj][0]

print(res)
n = int(input())
bfs_dic = [{} for i in range(n)]
ans = [0 for i in range(n-1)]

def bfs(pn, pc, node):
    c = 1
    max_c = 0
    
    if len(bfs_dic[node]) != 1 or pc == 0: #葉は見ない(葉でも最初だけは子を見る)
        for k,v in bfs_dic[node].items():
            if k == pn: continue #親と同じなら無視
            if pc == c:                 #親と色被っちゃったら色変え
                c+=1
            ans[v] = c
            maxable_c = bfs(node, c, k)
            if max_c < maxable_c:
                max_c = maxable_c
            c+=1                        #子と自分の間に色割り当てて色変える
        if max_c < c-1:
            return c-1
        else:
            return max_c
    return 1                                        #葉やったら1色しか使っとらん
            
for i in range(n-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    bfs_dic[a][b] = i
    bfs_dic[b][a] = i

print(bfs(-1, 0, 0))
for i in ans:
    print(i)

### FIXED CODE ###

import sys

sys.setrecursionlimit(100000)
n = int(input())
bfs_dic = [{} for i in range(n)]
ans = [0 for i in range(n-1)]

def bfs(pn, pc, node):
    c = 1
    max_c = 0
    
    if len(bfs_dic[node]) != 1 or pc == 0: #葉は見ない(葉でも最初だけは子を見る)
        for k,v in bfs_dic[node].items():
            if k == pn: continue #親と同じなら無視
            if pc == c:                 #親と色被っちゃったら色変え
                c+=1
            ans[v] = c
            maxable_c = bfs(node, c, k)
            if max_c < maxable_c:
                max_c = maxable_c
            c+=1                        #子と自分の間に色割り当てて色変える
        if max_c < c-1:
            return c-1
        else:
            return max_c
    return 1                                        #葉やったら1色しか使っとらん
            
for i in range(n-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    bfs_dic[a][b] = i
    bfs_dic[b][a] = i

print(bfs(-1, 0, 0))
for i in ans:
    print(i)
n = int(input())

print(n//2-not(n%2))

### FIXED CODE ###

n = int(input())

print(n//2-bool(not(n%2)))
def solve(stns, idx, mem):

    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 11
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+2])

    min_cost = min(step1, step2)
    mem[idx] = min_cost 

    return min_cost



def take_input():
    n = input()
    stns = [int(x) for x in input().split(' ')]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()

### FIXED CODE ###

import sys
def solve(stns, idx, mem):

    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        # print(idx)  
        # final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        final_step = abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 11
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 2, mem) + abs(stns[idx] - stns[idx+2])

        min_cost = min(step1, step2)
        mem[idx] = min_cost 

        return min_cost



def take_input():
    # n = input()
    # stns = [int(x) for x in input().split(' ')]



    reader = (s.rstrip() for s in sys.stdin)
    input = reader.__next__
    sys.setrecursionlimit(1000000)
    # do magic here
    n = int(input())
    stns = [int(x) for x in input().split()]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()
def L():
    return list(map(int, input().split()))

[x,y]=L()

if x%y==0:
  print(-1)
else:
  print x

### FIXED CODE ###

def L():
    return list(map(int, input().split()))

[x,y]=L()

if x%y==0:
  print(-1)
else:
  print(x)
import sys
sys.setrecursionlimit(100000)

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

tree_list=[]
for i in range(N+1):
  tree_list.append([])

for i in range(N-1):
  a,b=map(int,input().split())
  tree_list[a].append(b)
  
dic_score={}
for i in range(Q):
  p,x=map(int,input().split())
  if p in dic_score:
    dic_score[p]+=x
  else:
    dic_score[p]=x

#print(tree_list)  
ans_list=[0]*(N+1)

def dfs(v,s):
  score=s
  if v in dic_score:
    score+=dic_score[v]
    
  ans_list[v]+=score
  for vv in tree_list[v]:
    #dfs(vv,score)

dfs(1,0)
#print(ans_list)

ans_list_str=[]
for i in range(1,N+1):
  ans_list_str.append(str(ans_list[i]))

print(" ".join(ans_list_str))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input=sys.stdin.readline

def dfs(u,par):
  ans_list[u]+=ans_list[par]  
  for v in tree_list[u]:
    if v!=par:
      dfs(v,u)      
  return

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

tree_list=[[] for _ in range(N+1)]
for i in range(N-1):
  a,b=map(int,input().split())
  tree_list[a].append(b)
  tree_list[b].append(a)
#print(tree_list)

ans_list=[0]*(N+1)
for i in range(Q):
  p,x=map(int,input().split())
  ans_list[p]+=x

dfs(1,0)

print(*ans_list[1:])
#                           जय श्री राम

import sys; import math; from collections import *
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().split())
def get_list(): return list(get_ints())
def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9+7); SEXYMOD = 998244353; MAXN = int(1e5)

sys.stdin  = open("input.txt","r"); sys.stdout = open("output.txt","w")

# for _testcases_ in range(int(input())):
start =  26
n = int(input())
ans = []
while n:
    ans.append(n%26)
    n //= 26
# print(ans)
ans = ans[::-1]
for i in ans:
    if i == 0:
        i = 26
    printspx(chr(i+ord('a')-1))



'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

### FIXED CODE ###

#                           जय श्री राम

import sys; import math; from collections import *
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().split())
def get_list(): return list(get_ints())
def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9+7); SEXYMOD = 998244353; MAXN = int(1e5)

# sys.stdin  = open("input.txt","r"); sys.stdout = open("output.txt","w")

# for _testcases_ in range(int(input())):
n = int(input())
ans = []
while n:
    n -= 1
    n, r = divmod(n, 26)
    ans.append(chr(ord('a') + r))
print("".join(reversed(ans)))



'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
def lcs(s, t):
    '''s,tは文字列をリスト化したもの'''
    n = len(s)
    m = len(t)
    s.insert(0, '$')
    t.insert(0, '%')
    dp = [[0 for _j in range(m + 2)] for _i in range(n + 2)]
    dp[0][0] = 0
    for i in range(n+1):
        for j in range(m+1):
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]))
    # return dp[n][m]
    '''復元する'''
    length = dp[n][m]
    ans = ['']*(length+1)
    while(length > 0):
        if(s[n] == t[m]):
            ans[length] = s[n]
            n-=1
            m-=1
            length-=1
        elif(dp[n][m] == dp[n - 1][m]):
            n-=1
        else:
            m-=1
    return ''.join(ans)
# END CUT HERE

def ALDS1_10_C():
    q = ii()
    for _ in range(q):
        s = li()
        t = li()
        print(lcs(s, t))

def EDPC_F():
    s = li()
    t = li()
    print(lcs(s,t))


if __name__ == '__main__':
    # ALDS1_10_C()
    EDPC_F()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
def lcs(s, t):
    '''s,tは文字列をリスト化したもの'''
    n = len(s)
    m = len(t)
    s.append('$')
    t.append('%')
    dp = [[0 for _j in range(m + 2)] for _i in range(n + 2)]
    dp[0][0] = 0
    for i in range(n+1):
        for j in range(m+1):
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]))
    # return dp[n][m]
    '''復元する'''
    length = dp[n][m]
    ans = ['']*(length+1)
    while(length > 0):
        if(s[n] == t[m]):
            ans[length] = s[n]
            n-=1
            m-=1
            length-=1
        elif(dp[n+1][m+1] == dp[n][m+1]):
            n-=1
        else:
            m-=1
    return ''.join(ans[1:])
# END CUT HERE

def ALDS1_10_C():
    q = ii()
    for _ in range(q):
        s = li()
        t = li()
        print(lcs(s, t))

def EDPC_F():
    s = li()
    t = li()
    print(lcs(s,t))


if __name__ == '__main__':
    # ALDS1_10_C()
    EDPC_F()
import math
N, M = map(int, input().split())
S = input()
T = input()
g = math.gcd(N, M)
flag = True
n = int(N / g)
m = int(M / g)
for k in range(g):
  flag *= int(S[n*k] == T[m*k])
if flag == 0:
  out = -1
else:
  out = n * m * g
print(out)

### FIXED CODE ###

import fractions
N, M = map(int, input().split())
S = input()
T = input()
g = fractions.gcd(N, M)
n = N // g
m = M // g
out = n * m * g
for k in range(g):
  if S[k * n] != T[k * m]:
    out = -1
    break
print(out)
import math

A,B,C,D = map(int,input().split())
A -= 1
CD = C*D // math.gcd(C,D)
a = A - (A//C + A//D - A//CD)
b = B - (B//C + B//D - B//CD)
print(b-a)

### FIXED CODE ###

def gcd(x,y):
	x, y = max(x,y), min(x,y)
	while(y):
		x, y = y, x%y
	return x
A,B,C,D = map(int,input().split())
A -= 1
CD = C*D // gcd(C,D)
a = A - (A//C + A//D - A//CD)
b = B - (B//C + B//D - B//CD)
print(b-a)
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
x = input()

p = [-1 for _ in range(2*(10**5)+1)]
cnt = x.count('1')

def calc(a):
  #print('a=',a)
  if p[a] != -1:
    return p[a]
  else:
    if a == 0:
      ret = 0
    else:
      b = bin(a).count('1')
      ret = 1+calc(a%b)
    p[a] = ret
    return ret

x0 = int(x,2)%(cnt-1)
x1 = int(x,2)%(cnt+1)
for i in range(n):
  xx = pow(2,n-i-1)
  y = list(x)
  if y[i] == '0':
    print(calc((x1+xx%(cnt+1))%(cnt+1))+1)
  else:
    print(calc((x0-xx%(cnt-1))%(cnt-1))+1)
  

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
x = input()

p = [-1 for _ in range(2*(10**7)+1)]
cnt = x.count('1')

def calc(a):
  #print('a=',a)
  if 0 <= a <= 2*(10**7) and  p[a] != -1:
    return p[a]
  else:
    if a == 0:
      ret = 0
    else:
      b = bin(a).count('1')
      ret = 1+calc(a%b)
    if 0 <= a <= 2*(10**7):
      p[a] = ret
    return ret

if cnt > 1:
  x0 = int(x,2)%(cnt-1)
  xx0 = [1]
  for i in range(n+1):
    xx0.append((xx0[-1]*2)%(cnt-1))
x1 = int(x,2)%(cnt+1)
xx1 = [1]
for i in range(n+1):
  xx1.append((xx1[-1]*2)%(cnt+1))

y = list(x)  
for i in range(n):
  if y[i] == '0':
    xx = xx1[n-i-1]
    print(calc((x1+xx)%(cnt+1))+1)
  else:
    if cnt == 1:
      print(0)
    else:
      xx = xx0[n-i-1]
      print(calc((x0-xx)%(cnt-1))+1)
h, m = map(int, input().split())

count = ((h //2) * m) + ((h %2) *((m //2) + (m %2))
print(count)

### FIXED CODE ###

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

if h == 1 or m == 1:
    count = 1
else:
    count = ((h //2) * m) + ((h %2) *((m //2) + (m %2)))
print(count)
import queue
n, m = map(int, input().split())
route = [[] for _ in range(n)]
vals = []
for _ in range(m):
    a, b = map(int, input().split())
    route[a-1].append(b-1)
    route[b-1].append(a-1)
    vals.append([a-1, b-1])
ans = m
for i in range(m):
    route2 = set()
    q = queue.Queue()
    q.put(i)
    try:
        route[vals[i][0]].remove(vals[i][1])
        route[vals[i][1]].remove(vals[i][0])
    except:
        pass
    while not q.empty():
        a = q.get()
        if not a in route2:
            route2.add(a)
            for j in route[a]:
                q.put(j)
        if len(route2) == n:
            ans -= 1
            break
    try:
        route[vals[i][0]].append(vals[i][1])
        route[vals[i][1]].append(vals[i][0])
    except:
        pass
print(ans)
        


### FIXED CODE ###

import queue
n, m = map(int, input().split())
route = [[] for _ in range(n)]
vals = []
for _ in range(m):
    a, b = map(int, input().split())
    route[a-1].append(b-1)
    route[b-1].append(a-1)
    vals.append([a-1, b-1])
ans = m
for i in range(m):
    route2 = set()
    q = queue.Queue()
    q.put(0)
    route[vals[i][0]].remove(vals[i][1])
    route[vals[i][1]].remove(vals[i][0])
    while not q.empty():
        a = q.get()
        if not a in route2:
            route2.add(a)
            for j in route[a]:
                q.put(j)
        if len(route2) == n:
            ans -= 1
            break
    route[vals[i][0]].append(vals[i][1])
    route[vals[i][1]].append(vals[i][0])
print(ans)
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
tempT, tempA = 0, 0
for i in range(N):
	if(T[i] > tempT):
		tempT = L[i] = T[i]
		L.append(tempT)
		unknowL.append(0)
	else:
		unknowL.append(T[i])
		L.append(0)
for i in range(N):
	val = A.pop()
	if(A[i] > tempA):
		if(L[i] != 0 and L[i] != val):
			print(0)
			exit()
		tempA = L[i] = val 
		unknowL[i] = 0
	else:
		unknowL[i] = min(unknowL[i], val)
P = 1 
for i in unknowL:
	if(i != 0):
		P *= i	
print(P % (10**9 +7))


### FIXED CODE ###

def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
t = [(i != j, i) for i, j in zip(T, [None] + T)]
a = [(i != j, i) for i, j in zip(A, (A + [None])[1:])]
P = 1
for p, q in zip(t, a):
	if(p[0]):
		if(q[0]):
			if(p[1] != q[1]):
				print(0)
				exit()
		else:
			if(q[1] < p[1]):
				print(0)
				exit()
	elif(q[0]):
		if(p[1] < q[1]):
			print(0)
			exit()
	else:
		P = P * min(p[1], q[1]) % (10 ** 9 + 7)
print(P)
edu
cat
ion

### FIXED CODE ###

A = input()
B = input()
C = input()

print(A[0] + B[1] + C[2])
import sys

while True:
    
    ins = input().split()
    h = int(ins[0])
    w = int(ins[1])

    if h == 0 and w == 0:
        break
        
    for i in range(h):
        for j in range(w-1):
            sys.stdout.write("#")
        print("#")
        
    print("")

### FIXED CODE ###

import sys

while True:
    
    ins = input().split()
    h = int(ins[0])
    w = int(ins[1])

    if h == 0 and w == 0:
        break
        
    for i in range(h):
        for j in range(w-1):
            sys.stdout.write("#")
        print("#")
        
    print("")
a,b=int(input())
print(max(a,b)+max(max(a,b)-1,min(a,b)))

### FIXED CODE ###

a,b=map(int,input().split())
print(max(a,b)+max(max(a,b)-1,min(a,b)))