#include <bits/stdc++.h>
using namespace std;
int arr[10], mod = 100000;
char k;
long long pwm(long long b, long long p) {
  long long m = b, ret = 1;
  while (p) {
    if (p & 1) ret = (ret * m) % mod;
    m = (m * m) % mod;
    p >>= 1;
  }
  return ret;
}
int main() {
  for (int i = 0; i < 5; ++i) {
    cin >> k;
    arr[i] = k - '0';
  }
  swap(arr[1], arr[4]);
  swap(arr[1], arr[2]);
  int n = 0;
  for (int i = 0; i < 5; ++i) n = n * 10 + arr[i];
  int res = pwm(n, 5);
  printf("%05d\n", res);
}
