#include #include #include #include #include #include #include using namespace std; typedef long long LL; int main(){ string ns, ms; cin >> ns >> ms; LL N = ns[ns.size()-1] - '0'; LL M = ms[ms.size()-1] - '0'; if(ms.size() >= 2) M += 10 * (ms[ms.size()-2]-'0'); LL ans = 1; if(N == 0) ans = 0; for(int i = 0; i < M; i++){ ans = ans*N % 10; } cout << ans << endl; return 0; }