#include <bits/stdc++.h>
using namespace std;
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long arr[5] = {}, x = 10;
  for (int i = 0; i < 5; i++) {
    arr[i] = n % x;
    n /= 10;
  }
  long long y =
      arr[4] * 10000 + arr[2] * 1000 + arr[0] * 100 + arr[1] * 10 + arr[3];
  x = 1;
  for (int i = 0; i < 5; i++) {
    x *= y;
    x %= 100000;
  }
  stringstream ss;
  string s;
  ss << x;
  ss >> s;
  for (int i = s.size(); i < 5; i++) cout << '0';
  cout << s << endl;
  return 0;
}
