#include <bits/stdc++.h>
using namespace std;
void Swap(char *a, char *b) {
  char c = *a;
  *a = *b;
  *b = c;
}
int returnDigits(unsigned long long n) {
  int count = 0;
  while (n > 0) {
    ++count;
    n /= 10;
  }
  return count;
}
int main() {
  char input[6];
  cin >> input;
  Swap(&input[1], &input[2]);
  Swap(&input[2], &input[4]);
  int i = 0, num = 0;
  while (i < 5) {
    num *= 10;
    num += ((int)input[i] - (int)'0');
    ++i;
  }
  unsigned long long ans = num;
  unsigned long long subtract = 0, j = 0;
  i = 0;
  while (i < 4) {
    ans = (num * ans);
    subtract = ans;
    j = 0;
    while (j < 5) {
      subtract /= 10;
      ++j;
    }
    j = 0;
    while (j < 5) {
      subtract *= 10;
      ++j;
    }
    ans = ans - subtract;
    ++i;
  }
  if (ans == 0) {
    cout << "00000" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
