#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m = 0, f, g = 1;
  string s;
  cin >> s;
  swap(s[1], s[2]);
  swap(s[2], s[4]);
  for (int i = 0; i < 5; i++) {
    m *= 10;
    m += s[i] - '0';
  }
  for (int i = 0; i < 5; i++) {
    g *= m;
    g %= 100000;
  }
  if (g == 0) {
    cout << "00000";
    return 0;
  }
  int h = log(g) + 1;
  for (int i = 0; i < 5 - h; i++) cout << 0;
  cout << g;
}
