i,I=int,input print(pow(i(I()),i(I()),10))