#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const long long N = 1e5 + 5, M = 1e5;
char ch[5];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, i, j, k, l;
  string s;
  cin >> s;
  ch[2] = s.back();
  s.pop_back();
  ch[3] = s.back();
  s.pop_back();
  ch[1] = s.back();
  s.pop_back();
  ch[4] = s.back();
  s.pop_back();
  ch[0] = s.back();
  n = atoi(ch);
  k = n;
  if (n % 10 == 0 && n % 100 == 0) {
    return cout << string(5, '0'), 0;
  }
  for (i = 0; i < 4; i++) {
    n = (n * k) % M;
  }
  cout << n << endl;
}
