#include <bits/stdc++.h>
long long quick_pow(long long a, long long b, long long r) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % r;
    a = (a * a) % r;
    b >>= 1;
  }
  return ans;
}
int main() {
  char a[10];
  while (~scanf("%s", a)) {
    int n;
    n = (a[0] - '0') * 10000 + (a[2] - '0') * 1000 + (a[4] - '0') * 100 +
        (a[3] - '0') * 10 + (a[1] - '0');
    if (!n)
      puts("00001\n");
    else {
      int x, y, count = 1;
      y = x = quick_pow(n, 5, 100000);
      while (x > 9) x /= 10, count++;
      for (int i = 1; i <= 5 - count; i++) printf("0");
      printf("%d\n", y);
    }
  }
  return 0;
}
