#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long k, s1 = 1, s2, ans = 0;
string second, s3;
int32_t main() {
  cin >> second;
  k = (second[1] - '0') + 10 * (second[3] - '0') + (second[4] - '0') * 100 +
      (second[2] - '0') * 1000 + (second[0] - '0') * 10000;
  for (long long i = 0; i < 5; i++) s1 = (s1 * k) % 100000;
  s2 = s1;
  if (s1 == 0) {
    ans++;
  }
  while (s2 != 0) {
    ans++;
    s2 = s2 / 10;
  }
  if (ans < 5) {
    for (long long i = 0; i < 5 - ans; i++) cout << 0;
    cout << s1;
  } else {
    ans = 0;
    while (s1) {
      s3.push_back(s1 % 10 + '0');
      s1 = s1 / 10;
      ans++;
      if (ans == 5) {
        break;
      }
    }
    reverse(s3.begin(), s3.end());
    cout << s3;
  }
  return 0;
}
