#include <bits/stdc++.h>
using namespace std;
long d[5] = {0, 2, 4, 3, 1};
long toInt(string x) {
  long tmp = 0;
  for (long i = x.length() - 1, j = 1; i >= 0; --i, j *= 10)
    tmp += (x[i] - '0') * j;
  return tmp;
}
long long Pow(long long a, long x) {
  if (x == 1) return a;
  long long tmp = Pow(a, x >> 1);
  tmp = (tmp * tmp) % long(1e5);
  return (x & 1) ? (tmp * a) % long(1e5) : tmp;
}
int main() {
  string n, N = "";
  cin >> n;
  for (long i = 0; i < 5; ++i) N += n[d[i]];
  long NN = toInt(N);
  long long res = Pow(NN, 5);
  if (!res)
    printf("00000");
  else {
    long tmp = log10(res) + 1;
    for (long i = 1; i <= 5 - tmp; ++i) printf("0");
    printf("%I64d", res);
  }
  return 0;
}
