real = input()
mirror = ''
if real[-1] == '0':
    real = real[:-1]
    real = real[::-1]
else:
    real = real[::-1]
for i in range(len(real)):
    if real[i] == '5':
        mirror += '2'
    elif real[i] == '2':
        mirror += '5'
    else:
        mirror += real[i]
print(int(mirror))
