#include <bits/stdc++.h>
int main() {
  long long n;
  scanf("%lld", &n);
  long long a, b;
  a = n / 10000 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 +
      n / 10 % 10 * 10 + n / 1000 % 10;
  b = (a % 100000 * a % 100000 * a % 100000 * a % 100000 * a % 100000) % 100000;
  if (b == 0)
    printf("00000\n");
  else
    printf("%lld\n", b);
  return 0;
}
