k = int(input())
number = str(k)
mirror = {'1': '1', '2': '5', '3': '3', '4': '7', '5': '2', '6': '9', '7': '4', '8': '8', '9': '6', '0': '0'}
mirrored_number = ""
for digit in number:
    mirrored_number += mirror[digit]
mirrored_number = int(mirrored_number)
print(mirrored_number)
