#include using namespace std; int main() { int N; int M; cin >> N; cin >> M; int n = N % 10; int A = n; for (int i = 0; i < M-1; i++) { A *= n; if (A >= 10) { A %= 10; } } cout << A << endl; }