a = list(map(int, input().split())) print((pow(a[0],2)+pow(a[1],2)+pow(a[2],2)\ +pow(a[3],2)+pow(a[4],2))%10)