#include <bits/stdc++.h>
using namespace std;
char str[10];
long long num;
const long long MOD = 100000;
long long D(char ch) { return (long long)ch - (long long)'0'; }
void EnchomSolve() {
  long long rem;
  scanf("%s", str + 1);
  num = D(str[1]);
  num = num * 10 + D(str[3]);
  num = num * 10 + D(str[5]);
  num = num * 10 + D(str[4]);
  num = num * 10 + D(str[2]);
  rem = num;
  num = num * rem * rem;
  num %= MOD;
  num = num * rem * rem;
  num %= MOD;
  if (num < 10000) printf("0");
  if (num < 1000) printf("0");
  if (num < 100) printf("0");
  if (num < 10) printf("0");
  printf("%lld\n", num);
  return;
}
int main() {
  EnchomSolve();
  return 0;
}
