#include <bits/stdc++.h>
using namespace std;
const long long M = 100000;
string s;
int main() {
  cin >> s;
  string sp;
  sp += s[0];
  sp += s[2];
  sp += s[4];
  sp += s[3];
  sp += s[1];
  long long num = 0;
  for (int i = 0; i < 5; i++) {
    num *= 10;
    num += sp[i] - '0';
  }
  long long ans = 1;
  for (int i = 0; i < 5; i++) {
    ans *= num;
    ans %= M;
  }
  string spp;
  while (ans > 0) {
    spp += (ans % 10) + '0';
    ans /= 10;
  }
  while ((int)spp.size() < 5) spp += '0';
  reverse(spp.begin(), spp.end());
  cout << spp << endl;
  return 0;
}
