#include <bits/stdc++.h>
using namespace std;
string string_mul(string a, string b) {
  long int len, len2, i, j, temp = 0, s[5000] = {0}, m = 0, c[2000], d[2000];
  len = a.size();
  len2 = b.size();
  for (i = len; i > 0; i--) c[len - i] = a[i - 1] - 48;
  for (i = len2; i > 0; i--) d[len2 - i] = b[i - 1] - 48;
  for (i = 0; i < len2; i++) {
    temp = 0;
    for (j = 0; j < len; j++) {
      temp = s[i + j] + c[j] * d[i] + temp;
      s[i + j] = temp % 10;
      m = m + 1;
      temp = temp / 10;
    }
    if (temp > 0) {
      s[i + j] = temp;
      m = m + 1;
    }
  }
  int cc = 0;
  for (i = 0; i < m; i++) {
    if (s[i] != 0) cc = 1;
  }
  string res;
  if (cc == 1) {
    for (i = m + 1; i >= 0; i--) {
      if (s[i] > 0)
        for (i = i; i >= 0; i--) res += (s[i] + 48);
    }
  } else
    res = "0";
  return res;
}
int main() {
  string st1, st2;
  int n, i;
  cin >> st1;
  st2 += st1[0], st2 += st1[2], st2 += st1[4], st2 += st1[3], st2 += st1[1];
  st1 = st2;
  for (i = 1; i <= 4; i++) {
    st2 = string_mul(st1, st2);
  }
  int len = st2.size();
  for (i = len - 5; i < len; i++) cout << st2[i];
  return 0;
}
