#include <bits/stdc++.h>
using namespace std;
unsigned long long n;
unsigned long long Cnk(unsigned long long n, unsigned long long k) {
  if (n < 0 || k > n) return 0;
  unsigned long long res = 1;
  unsigned long long t[32];
  for (int i = 0; i < 32; i++) t[i] = 0;
  for (int i = 2; i <= k; i++) t[i] = 1;
  for (unsigned long long x = n - k + 1; x <= n; x++) {
    res *= x;
    for (unsigned long long i = 2; i <= k; i++)
      if (t[i] && res % i == 0) {
        res /= i;
        t[i] = 0;
      }
  }
  return res;
}
char c[50];
int main() {
  cin >> c;
  swap(c[1], c[2]);
  swap(c[2], c[4]);
  for (int i = 0; i < 5; i++) c[i] -= '0';
  long long x = ((((c[0] * 10 + c[1]) * 10 + c[2]) * 10 + c[3]) * 10 + c[4]);
  long long res = 1;
  res = (res * x) % 100000;
  res = (res * x) % 100000;
  res = (res * x) % 100000;
  res = (res * x) % 100000;
  res = (res * x) % 100000;
  long long mot = 10000;
  while (mot && res / mot == 0) {
    cout << 0;
    mot /= 10;
  }
  if (mot) printf("%I64d", res);
  return 0;
}
