a,b,c,d,e=input().split(" ") a=int(a) b=int(b) c=int(c) d=int(d) e=int(e) s= a*a+b*b+c*c+d*d+e*e print(s%10)