#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  long long v = ((((s[0] - 48) * 10 + (s[2] - 48)) * 10 + (s[4] - 48)) * 10 +
                 (s[3] - 48)) *
                    10 +
                (s[1] - 48);
  long long res = v;
  for (int i = 1; i < 5; i++) {
    res = (res * v) % 100000;
  }
  if (res == 0) {
    cout << "00000";
    return 0;
  } else
    cout << res;
  return 0;
}
