#include <bits/stdc++.h>
using namespace std;
char s[6];
int a[6];
int main() {
  gets(s + 1);
  for (int i = 1; i <= 5; i++) a[i] = s[i] - '0';
  long long x = 10000 * a[1] + 1000 * a[3] + 100 * a[5] + 10 * a[4] + a[2];
  long long ans = 1;
  bool ok = false;
  for (int i = 1; i <= 5; i++) {
    if (1ll * ans * x > 100000) ok = true;
    ans = (1ll * ans * x) % 100000;
  }
  int t = 0;
  int b = ans;
  do {
    t++;
    b /= 10;
  } while (b != 0);
  t = 5 - t;
  if (ok)
    for (int i = 1; i <= t; i++) printf("0");
  printf("%d", ans);
  return 0;
}
