#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 = m.length() >= 2 ? stoi(""s + m[m.length()-2] + m[m.length()-1]) : stoi(m[m.length()-1] + ""s); mval = m.length() >= 2 && mval == 0 ? 100 : mval; int result = nval == 0 ? 0 : 1; rep(i, mval) { result *= nval; result %= 10; } cout << result << endl; }