import sys



for line in sys.stdin:

    line = [int(v) for v in line.strip()]

    while len(line) > 1:

        line = [line[i]+line[i+1] for i in range(len(line)-1)]

    print((str(line[0])[len(str(line[0]))-1]))
while True:

    try:

        nums = eval(input())

    except:

        break

    a = list(map(int, list(nums)))

    while len(a) > 1:

        a = list(map(int, [str(a[i]+a[i+1])[-1] for i in range(len(a)-1)]))

    print((*a))
import sys

for line in sys.stdin:
    line = [int(v) for v in line.strip()]
    while len(line) > 1:
        line = [line[i] + line[i + 1] for i in range(len(line) - 1)]
    print((str(line[0])[len(str(line[0])) - 1]))

while True:
    try:
        nums = eval(input())
    except:
        break
    a = list(map(int, list(nums)))
    while len(a) > 1:
        a = list(map(int, [str(a[i] + a[i + 1])[-1] for i in range(len(a) - 1)]))
    print((*a))

-import sys - -for line in sys.stdin: -    line = [int(v) for v in line.strip()] -    while len(line) > 1: -        line = [line[i] + line[i + 1] for i in range(len(line) - 1)] -    print((str(line[0])[len(str(line[0])) - 1])) +while True: +    try: +        nums = eval(input()) +    except: +        break +    a = list(map(int, list(nums))) +    while len(a) > 1: +        a = list(map(int, [str(a[i] + a[i + 1])[-1] for i in range(len(a) - 1)])) +    print((*a))