#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long x) {
  if (x == 0)
    return 1;
  else if (x % 2 == 0)
    return power(a * a, x / 2);
  else
    return a * power(a * a, (x - 1) / 2);
}
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    int m = (n / 10000) * 10000 + ((n / 100) % 10) * 1000 + (n % 10) * 100 +
            ((n / 10) % 10) * 10 + (n / 1000) % 10;
    long long ans = m, a = 4;
    while (a--) ans = (ans * m) % 100000;
    int temp = ans, digit = 0;
    if (ans == 0) {
      cout << "00000";
      return 0;
    }
    while (temp != 0) {
      digit++;
      temp = temp / 10;
    }
    int x = 5 - digit;
    while (x--) {
      cout << "0";
    }
    cout << ans;
  }
  return 0;
}
