#include #include #include using namespace std; typedef long long LL; LL modpow(LL x, LL n, LL mod) { LL a = 1; for (LL k = x; n > 0; n >>= 1, k = (k*k) % mod) { if (n & 1) { a = (a*k) % mod; } } return a; } int main(int argc, char *argv[]) { int N, M; cin >> N >> M; LL ans = modpow(N, M, 10); cout << ans << endl; return 0; }