#include #include using namespace std; int getnum(char c){ return c - '0'; } int main() { string N, M; cin >> N >> M; int a = getnum(N[N.size() - 1]); int b = getnum(M[M.size() - 1]); if (M.size() != 1) b += getnum(M[M.size() - 2]) * 10; if (M.size() >= 3) b += 100; int ans = 1; for (int i = 0; i < b; i++) { ans *= a; ans %= 10; } cout << ans << endl; }