#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int s = (n / 10000) * 10000 + ((n / 100) % 10) * 1000 +
                    (n % 10) * 100 + ((n / 1000) % 10) + ((n / 10) % 10) * 10;
  n = s;
  for (int i = 1; i <= 4; i++) {
    n = n * s;
    n = n % (long long int)(100000);
  }
  int y = n;
  int t = 1;
  while (y != 0) {
    y = y / 10;
    t++;
  }
  if (n == 0) {
    cout << 0 << 0 << 0 << 0 << 0;
    return 0;
  }
  for (int i = t; i <= 5; i++) cout << 0;
  cout << n;
}
