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