#include <bits/stdc++.h>
using namespace std;
int main() {
  int m;
  cin >> m;
  vector<int> n;
  for (int i = 0; i < 5; i++) {
    n.push_back(m % 10);
    m = m / 10;
  }
  long long int h = 10000 * n[4] + n[2] * 1000 + n[0] * 100 + n[1] * 10 + n[3];
  long long int a = 1;
  for (int j = 0; j <= 4; j++) {
    a = a * h;
    a = a % 100000;
  }
  printf("%05lld", a);
}
