#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n1, long long n2) {
  if (n1 % n2 == 0) return n2;
  return gcd(n2, n1 % n2);
}
long long powmod(long long base, long long exponent) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % 100000;
    base = (base * base) % 100000;
    exponent /= 2;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, temp;
  cin >> n;
  temp = n;
  long long arr1[5];
  int k = 0;
  while (temp) {
    arr1[k++] = temp % 10;
    temp /= 10;
  }
  long long arr[5];
  arr[0] = arr1[3];
  arr[2] = arr1[0];
  arr[3] = arr1[2];
  arr[1] = arr1[1];
  arr[4] = arr1[4];
  n = 0;
  temp = 1;
  for (k = 0; k < 5; k++) {
    n += temp * arr[k];
    temp *= 10;
  }
  long long answer = powmod(n, 5);
  int cnt = 0;
  temp = answer;
  while (temp) {
    temp /= 10;
    cnt++;
  }
  for (int i = 0; i < 4 - cnt; i++) cout << 0;
  cout << answer;
  return 0;
}
