#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int pow_mod(ll x, ll n, int m) { ll res = 1; for (; n > 0; n >>= 1) { if (n & 1) res = (res * x) % m; x = (x * x) % m; } return res; } int main() { string N, M; cin >> N >> M; int x = N.back() - '0'; if (M == "0") { cout << 1 << endl; return 0; } if (x == 0 || x == 5) { cout << x << endl; return 0; } if (M.length() >= 5) { if (x == 1 || x == 3 || x == 9) { cout << 1 << endl; return 0; } else { cout << 6 << endl; return 0; } } stringstream ss(M); int y; ss >> y; cout << (x, y, 10) << endl; }