aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762



s = input()
Mask = [False]*s.__len__()


def Cumple(indices):
    for i in range(0,len(indices)):#purgando las combinaciones q tienen indices no ordenados crecientemente
        for j in range(i,len(indices)):
            if indices[i] > indices[j]:
                return False

    if s[indices[0]-1]=="a" and s[indices[indices.__len__()-1]-1]=="a":    
        for i in range(indices[0],indices[len(indices)-1]-1):
            if s[i]=="b":
                return True 
    if len(indices) ==1 and s[indices[0]-1]=="a":
        return True

def Variaciones(n, m, solucion,g_solution):
    if solucion.__len__() <= m and solucion.__len__() !=0:
        if Cumple(solucion):
            g_solution += [solucion.copy()]  
    if solucion.__len__() ==m:       
            return
    for i in range(1,n+1):
        if not Mask[i-1]:
            Mask[i-1] = True
            solucion += [i]
            Variaciones(n,m,solucion,g_solution)
            Mask[i-1]= False
            solucion.pop(solucion.__len__()-1)
    return g_solution

b = Variaciones(s.__len__(),2,[],[])
k = 1
while k <3:
   for i in range(0, b.__len__()):
       if len(b[i]) ==k:
           print(b[i])
   k+=1