#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167772160000")
template <typename T>
using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T>
using max_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  string t = s;
  t[1] = s[2];
  t[2] = s[4];
  t[4] = s[1];
  long long base = stoi(t);
  long long res = 1;
  for (int i = (0); i < (5); i++) {
    res = (res * base) % 100000;
  }
  ostringstream ss;
  ss << res;
  string resS = ss.str();
  while (resS.length() < 5) resS = "0" + resS;
  cout << resS;
  return 0;
}
