k = input().strip()

mirrored_digits = {
    '0': '0',
    '1': '1',
    '6': '9',
    '8': '8',
    '9': '6'
}

mirror = ''
for digit in k[::-1]:
    if digit in mirrored_digits:
        mirror += mirrored_digits[digit]
    else:
        mirror += digit

print(mirror.lstrip('0'))  
