#include using namespace std; template T gcd(T x, T y) { if (y == 0) return x; return gcd(y, x % y); } template T lcm(T x, T y) { if (x == 0 || y == 0) return 0; return x / gcd(x, y) * y; } int main() { string N; cin >> N; string M; cin >> M; const int mod = 10; int n = N[N.size() - 1] - '0'; int m = M[M.size() - 1] - '0'; int ans = 1; for (int i = 0; i < m; i++) { ans *= n; ans %= mod; } cout << ans << endl; }