#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define llong long long int main() { string n, m; cin >> n >> m; int nval = stoi(n[n.length()-1] + ""s); int mval = stoi(m[m.length()-1] + ""s); int result = 1; rep(i, mval) result *= nval; cout << result % 10 << endl; }