#include #include using namespace std; int main(){ int n,m; cin >> n >> m; if(m == 0) cout << 1 << endl; else{ n %= 10; m %= 5; cout << int(pow(n,m)) % 10 << endl; } }