#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, b;
  string a;
  cin >> a;
  n = (a[0] - 48) * 10000 + (a[2] - 48) * 1000 + (a[4] - 48) * 100 +
      (a[3] - 48) * 10 + (a[1] - 48);
  b = n;
  b = (b * n) % 100000;
  b = (b * n) % 100000;
  b = (b * n) % 100000;
  b = (b * n) % 100000;
  if (b == 0) {
    cout << "00000";
  } else if (b < 10) {
    cout << "0000" << b;
  } else if (b < 100)
    cout << "000" << b;
  else if (b < 1000)
    cout << "00" << b;
  else if (b < 10000)
    cout << "0" << b;
  else
    cout << b;
}
