#include <bits/stdc++.h>
using namespace std;
long long n, one, two, three, four, five, o, t, th, f, fv;
long long putere(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2 == 0) return putere((a * a) % 100000, b / 2) % 100000;
  if (b % 2 == 1) return (a * putere(a, b - 1)) % 100000;
}
int main() {
  cin >> n;
  fv = n % 10;
  n /= 10;
  f = n % 10;
  n /= 10;
  th = n % 10;
  n /= 10;
  t = n % 10;
  n /= 10;
  o = n % 10;
  n /= 10;
  one = o;
  two = th;
  three = fv;
  four = f;
  five = t;
  n = 0;
  n *= 10;
  n += one;
  n *= 10;
  n += two;
  n *= 10;
  n += three;
  n *= 10;
  n += four;
  n *= 10;
  n += five;
  long long ans = 1;
  for (int i = 1; i <= 5; ++i) {
    ans *= n;
    ans %= 100000;
  }
  long long aux = ans, nrc = 0;
  while (aux) nrc++, aux /= 10;
  for (int i = 1; i <= 4 - nrc; ++i) cout << 0;
  cout << ans;
  return 0;
}
