#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> digit;
  for (int i = 0; i < 5; ++i) {
    digit.push_back(N % 10);
    N = (N - N % 10) / 10;
  }
  long long new_N = digit[4] * 10000 + digit[2] * 1000 + digit[0] * 100 +
                    digit[1] * 10 + digit[3];
  long long ans = new_N;
  for (int i = 0; i < 4; ++i) {
    ans = ans * new_N;
    ans = ans % 100000;
  }
  if (ans == 0) {
    cout << "00000" << endl;
  } else if (ans < 10) {
    cout << "0000" << ans << endl;
  } else if (ans < 100) {
    cout << "000" << ans << endl;
  } else if (ans < 1000) {
    cout << "00" << ans << endl;
  } else if (ans < 10000) {
    cout << "0" << ans << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
