#include <bits/stdc++.h>
using namespace std;
int main() {
  uint64_t n;
  cin >> n;
  int d[6];
  d[1] = n / 10000;
  d[2] = n / 1000 % 10;
  d[3] = n / 100 % 10;
  d[4] = n / 10 % 10;
  d[5] = n % 10;
  uint64_t re = d[1] * 10000 + d[3] * 1000 + d[5] * 100 + d[4] * 10 + d[2];
  uint64_t re2 = (re * re) % 100000;
  cout << setw(5) << setfill('0') << (re2 * re2 * re) % 100000;
  return 0;
}
