n = input()
n = [n[i] for i in range(len(n))]
n = n[::-1]
for i in range(len(n)):
    if n[i] == '2':
        n[i] = '5'
    elif n[i] == '5':
        n[i] = '2'
m = ''
for i in n:
    m += i
print(int(m))