#include <bits/stdc++.h>
using namespace std;
long long ModPow(long long a, long long x, long long p) {
  long long res = 1;
  while (x > 0) {
    if (x % 2 != 0) res = (res * a) % p;
    a = (a * a) % p;
    x /= 2;
  }
  return (res % p);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  int n = 0, x[] = {0, 2, 4, 3, 1}, i;
  cin >> s;
  for (i = 0; i < 5; i++) n = n * 10 + s[x[i]] - '0';
  n = (int)ModPow(n, 5, 100000);
  s = "";
  while (n > 0) {
    s += (n % 10 + '0');
    n /= 10;
  }
  while ((int)s.size() < 5) s += "0";
  reverse(s.begin(), s.end());
  cout << s << '\n';
  return 0;
}
