#include using namespace std; #define ll long long #define ull unsigned ll int powmod(ull x,ull y){ unsigned long long ans = 1; while(y--){ ans *= x; ans %= 10; } return ans; } int main(){ ull n,m; cin >> n >> m; cout << powmod(n,m) << endl; }