k = input()
str_out = ''
for str_in in k:
    if str_in == '2':
        str_out += '5'
    elif str_in == '5':
        str_out += '2'
    else:
        str_out += str_in
str_fin_out = int(str_out[::-1])
print(str_fin_out)
