#include <bits/stdc++.h>
using namespace std;
inline void splay(int &v) {
  v = 0;
  char c = 0;
  int p = 1;
  while (c < '0' || c > '9') {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = (v << 3) + (v << 1) + c - '0';
    c = getchar();
  }
  v *= p;
}
int main() {
  char s[9];
  scanf("%s", s + 1);
  s[1] -= '0';
  s[2] -= '0';
  s[3] -= '0';
  s[4] -= '0';
  s[5] -= '0';
  long long y = s[1] * 10000 + s[3] * 1000 + s[5] * 100 + s[4] * 10 + s[2] * 1;
  long long r = y;
  for (long long i = 1; i <= 4; i++) {
    r *= y;
    r %= 100000;
  }
  if (r < 10000) printf("0");
  if (r < 1000) printf("0");
  if (r < 100) printf("0");
  if (r < 10) printf("0");
  cout << r << endl;
}
