unswizzle

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from sys import stdin, stdout
input_number = str(int(stdin.read()))
output_number = ''
offset = 1
if len(input_number) == 1:
    output_digit = [0, 9, 5, 1, 6, 2, 7, 3, 8, 4][int(input_number)]  # magic!
    output_number = str(output_digit)
else:
    last_digit = int(input_number[-1])
    for i, input_digit in enumerate(reversed(input_number)):
        if i == len(input_number) - 1:
            output_digit = (int(input_digit)-int(last_digit)-offset - 1) % 9
            if output_digit == 0:
                output_digit = 9
        elif i == 0:
            output_digit = input_digit
        else:
            output_digit = (int(input_digit)-int(last_digit)-offset) % 10
            offset = offset + int(output_digit) + i
        output_number = str(output_digit) + output_number
stdout.write('%s\n' % output_number)