#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f, N = 1e7;
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
char s[10];
int d(char c) { return c - '0'; }
int main() {
  while (~scanf("%s", s)) {
    long long x = d(s[0]) * 10000 + d(s[2]) * 1000 + d(s[4]) * 100 +
                  d(s[3]) * 10 + d(s[1]);
    long long ans = x;
    for (int i = 1; i < 5; i++) ans = ans * x % 100000;
    printf("%05d", ans);
  }
  return 0;
}
