#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long int n = ((int)s[1] - '0') + 10 * ((int)s[3] - '0') +
                    100 * ((int)s[4] - '0') + 1000 * ((int)s[2] - '0') +
                    10000 * ((int)s[0] - '0');
  long long int result = (n * n) % 100000;
  result = (result * result) % 100000;
  result = (result * n) % 100000;
  int digits = (int)log10(result + 1);
  digits = 4 - digits;
  for (int i = 0; i < digits; i++) cout << '0';
  cout << result;
  return 0;
}
