#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n = 0;
  char str[10];
  gets(str);
  char num[10];
  num[0] = str[0];
  num[1] = str[2];
  num[2] = str[4];
  num[3] = str[3];
  num[4] = str[1];
  for (int i = 0; i < (int)5; i++) {
    n = n * 10 + (num[i] - '0');
  }
  long long ans = 1;
  for (int i = 0; i < (int)5; i++) {
    ans = ((ans % 100000) * (n % 100000)) % 100000;
  }
  if (ans == 0)
    cout << "00000" << endl;
  else if (ans < 10)
    cout << "0000" << ans << endl;
  else if (ans < 100)
    cout << "000" << ans << endl;
  else if (ans < 1000)
    cout << "00" << ans << endl;
  else if (ans < 10000)
    cout << "0" << ans << endl;
  else
    cout << ans << endl;
  return 0;
}
