#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2 = "", ans = "", tmp;
  cin >> s1;
  s1 = "#" + s1;
  s2 += s1[1];
  s2 += s1[3];
  s2 += s1[5];
  s2 += s1[4];
  s2 += s1[2];
  long long int num = 0, x, i;
  for (i = 0; i < s2.size(); i++) num = num * 10 + (s2[i] - '0');
  for (x = num, i = 1; i < 5; i++) num = (x * num) % 100000;
  for (i = 1; i <= 10000; i *= 10) {
    x = (num / i) % 10;
    tmp = x + '0';
    ans = tmp + ans;
  }
  cout << ans;
  return 0;
}
