#include<bits/stdc++.h>
using
namespace
std;
int
main(){
long
long
a,b;
cin>>a>>b;
int
sum = 1;
for
(
int
i=1;i<=b;i++){
sum=sum*a;
sum=sum%10;
}
cout<<sum;
return
0;
}
#include<bits/stdc++.h>
using
namespace
std;
int
main(){
long
long
a,b;
cin>>a>>b;
int
sum = 1;
for
(
int
i=1;i<=b;i++){
sum=sum*a;
sum=sum%10;
}
cout<<sum;
return
0;
}