a = input()
s = []
if '5' in a and '2' in a:
    for i in a:
        if int(i) == 2:
            s.append(5)
        elif int(i) == 5:
            s.append(2)    
        else:
            s.append(int(i))
    if s[len(s)-1] == 0:
        s.remove(0)
    print(*s[::-1], sep = '' )
else:
    for j in a:
        s.append(int(j))
    print(*s[::-1], sep = '' )
