Recovering a Damaged ISBN Digit

One digit of a 13-digit ISBN is replaced by '*', and you print the digit that makes the weighted checksum divisible by 10.

Easy2MathImplementationInterviewNo attempts yetTime limit1sMemory limit128 MB

Problem

An ISBN (International Standard Book Number) is the unique number assigned to every book published worldwide. It encodes information such as the country and the publisher, and it is written as 13 digits. The last digit is the check digit, which tells you whether the ISBN is correct. The check digit is chosen so that multiplying the digits from the left by the weights 1,3,1,3,1, 3, 1, 3, \dots and adding the products gives a sum divisible by 10. Written as a formula:

If the ISBN is abcdefghijklmabcdefghijklm, then a+3b+c+3d+e+3f+g+3h+i+3j+k+3l+m0(mod10)a+3b+c+3d+e+3f+g+3h+i+3j+k+3l+m \equiv 0 \pmod{10}.

That is, the check digit is m=(10(a+3b+c+3d+e+3f+g+3h+i+3j+k+3l)mod10)mod10m = (10 - (a+3b+c+3d+e+3f+g+3h+i+3j+k+3l) \bmod 10) \bmod 10.

If the remainder is 0, the check digit is 0.

Younghoon works as a librarian at a university central library. While sorting books he found one whose ISBN has a single damaged position. Write a program that recovers the digit that belongs there.

Input

The first line contains an ISBN of 13 characters. The damaged position is written as *. Exactly one of the first 12 positions is damaged, the check digit is never damaged, and every other position is a digit.

Output

Print the single digit that belongs in the * position.