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