#include int main() { char n[10004], m[10004]; scanf("%s%s", n, m); int ln, lm; for (ln = 0; n[ln] != '\0'; ln++); for (lm = 0; m[lm] != '\0'; lm++); int nn, mm; nn = n[ln - 1] - '0'; if (lm == 1) mm = m[0] - '0'; else mm = 10 * (m[lm - 2] - '0') + (m[lm - 1] - '0'); int res = nn; for (; mm > 1; mm--) res = res * nn % 10; printf("%d\n", res); return 0; }