Just look at the last digit of the last number. Here is some python code: calls = [int(x.strip()) for x in input().strip().split()] digit = calls[-1]%10 print( 10 if digit==0 else digit )