a, n = map(int, input().split()) M = 10 print(a**n%M)