#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
  cin >> S;
  string A = S;
  A[1] = S[2];
  A[2] = S[4];
  A[4] = S[1];
  reverse(A.begin(), A.end());
  string ans(30, '0');
  ans[0] = '1';
  for (int t = 0; t < 5; t++) {
    string tmp(30, '0');
    for (int i = 0; i < 5; i++) {
      for (int j = 0; j < 25; j++) {
        int num = (A[i] - '0') * (ans[j] - '0') + tmp[i + j] - '0';
        int cnt = 0;
        while (num >= 10) {
          tmp[i + j + cnt] = num % 10 + '0';
          cnt++;
          num = tmp[i + j + cnt] - '0' + num / 10;
        }
        tmp[i + j + cnt] = num + '0';
      }
    }
    ans = tmp;
  }
  string res = ans.substr(0, 5);
  reverse(res.begin(), res.end());
  cout << res;
  return 0;
}
