def mirror_number(number):
    mirror_dict = {
        '0': '0',
        '1': '1',
        '2': '5',
        '3': '3',
        '4': '4',
        '5': '2',
        '6': '6',
        '7': '7',
        '8': '8',
        '9': '9'
    }

    number_str = str(number).rstrip('0')

    reversed_str = number_str[::-1]

    mirrored_str = ''.join([mirror_dict[char] for char in reversed_str])
    
    return mirrored_str

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




