#include <bits/stdc++.h>
using namespace std;
const int MOD = 100 * 1000;
int main() {
  int arr[5];
  for (int i = 0; i < 5; i++) {
    char c;
    cin >> c;
    arr[i] = c - '0';
  }
  long long a =
      arr[1] + arr[3] * 10 + arr[4] * 100 + arr[2] * 1000 + arr[0] * 10000;
  long long b = a;
  for (int i = 1; i < 5; i++) {
    a *= b;
    a %= MOD;
  }
  string s;
  while (a > 0) {
    s += (a % 10) + '0';
    a /= 10;
  }
  while (s.size() != 5) s += '0';
  reverse(s.begin(), s.end());
  cout << s << endl;
}
