#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n;
  cin >> n;
  long long x = 0, p = n;
  long long a[5] = {100, 10, 1000, 1, 10000};
  for (int i = 0; i < 5; i++) {
    x += (n % 10) * a[i];
    n /= 10;
  }
  long long q = x;
  for (int i = 0; i < 4; i++) {
    x = x * q;
    x = x % 100000;
  }
  if (x == 0) {
    cout << "00000";
  } else {
    cout << x;
  }
  return 0;
}
