#include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,s,e) for (int i = int(s); i != int(e); i++) #define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) #define ISEQ(c) (c).begin(), (c).end() int main(){ string N; string M; cin >> N >> M; string N2 = N.substr(N.length()-1,1); int Nd = atoi(N2.c_str()); int Md; if (M.length() == 1){ Md = atoi(M.c_str()); if (Md == 0) { cout << 1 << endl; return 0; } }else{ string M2 = M.substr(M.length()-2,2); Md = atoi(M2.c_str()); } int ans = 1; if(Md == 0) Md += 4; FOR(i,0,Md){ ans = (ans * Nd)%10; } cout << ans << endl; return 0; }