swizzle

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from sys import stdin, stdout
input_number = str(int(stdin.read()))
output_number = ''
offset = 1
last_digit = 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) % 9 + 1
    elif i == 0:
        output_digit = input_digit
    else:
        output_digit = (int(input_digit)+int(last_digit)+offset) % 10
        offset = offset + int(input_digit) + i
    output_number = str(output_digit) + output_number
stdout.write('%s\n' % output_number)