input = "bbbab aaaaa ababa abbba babba aaaab babaa baabb aaaba bbbab ababa abbba babba babaa bbbaa abbab ababb abbbb baaab bbabb babba bbbaa baabb ababb abbaa bbabb aaaba ababb ababb abbaa baaaa ababa abbba bbabb aabbb babbb abbab aaabb abbbb babba bbaaa baaaa ababb ababb babba bbbbb bbbaa abaab babaa baaab ababb ababb bbbbb ababb abaaa baaaa abbba bbaba aaaab bbabb aabaa "

input = input.replace(" ", "")

states = {
    0: {'a': [0,2], 'b': [1,1]},
    1: {'a': [1,1], 'b': [0,2]},
    2: {'a': [1,1], 'b': [0,3]},
    3: {'a': [0,5], 'b': [1,3]},
    4: {'a': [0,1], 'b': [1,5]},
    5: {'a': [1,4], 'b': [0,4]},
}

chars = (' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '_', '_', '_', '_', '_')

res = ""
state = 0
for c in input:
    res = res + str(states[state][c][0])
    state = states[state][c][1]

for i in range(0, len(input)//5):
    c = chars[int(res[5*i:5*i+5], 2)]
    print(c.upper(), end='')
