#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 100, MAX = 1e6 + 5;
const long long INF = 1e18 + 5;
int main() {
  string s;
  cin >> s;
  long long n = (s[1] - '0') + (s[3] - '0') * 10 + (s[4] - '0') * 100 +
                (s[2] - '0') * 1000 + (s[0] - '0') * 10000;
  long long Ans = 1;
  for (int i = 0; i < 5; i++) {
    Ans = (Ans * n) % 100000;
  }
  string x = to_string(Ans);
  reverse(x.begin(), x.end());
  while (x.size() != 5) {
    x += '0';
  }
  reverse(x.begin(), x.end());
  cout << x << endl;
}
