[백준] A와 B2

 

문제

s = input()
t = input()

def func(t, s):
    if t == s:
        return 1
    if len(t) <= len(s):  
        return 0
    
    if t[-1] == 'A':  
        if func(t[:-1], s):
            return 1
    if t[0] == 'B':
        if func(t[::-1][:-1], s):
            return 1

    return 0

print(func(t, s))