isbn = input()
acc = 0
isOdd = False
for n in isbn[:12] :
    isOdd = not isOdd
    if n != '*' :
        if isOdd :
            acc += int(n)
        else :
            acc += 3*int(n)
    else :
        weight = 1 if isOdd else 3

for i in range(10) :
    if (i*weight + acc + int(isbn[12]))%10 == 0 :
        print(i)
        break