def mirror_number(number):
    number_str = str(number).rstrip('0')[::-1]

    mirrored_str = number_str.replace('2', 'X').replace('5', '2').replace('X', '5')
    
    return mirrored_str

number = input()
mirrored_number = mirror_number(number)
print(mirrored_number)
