#include #include #include void solve() { std::string s, t; std::cin >> s >> t; std::reverse(s.begin(), s.end()); s.resize(1); std::reverse(s.begin(), s.end()); std::reverse(t.begin(), t.end()); t.resize(2, '0'); std::reverse(t.begin(), t.end()); int n = std::stoi(s), m = std::stoi(t); if (n == 0) { std::cout << 0 << std::endl; return; } int ans = 1; for (int i = 0; i < m; ++i) { (ans *= n) %= 10; } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }