k = input().strip()
mirror_number = ""
for digit in k:
    if digit == '6':
        mirror_number += '9'
    elif digit == '9':
        mirror_number += '6'
    else:
        mirror_number += digit

print(int(mirror_number))
