#include <bits/stdc++.h>
using namespace std;
;
const int maxn = 1e5 + 10;
unsigned long long n;
int main() {
  cin >> n;
  int n1 = (n / 10000);
  int n2 = (n / 1000) % 10;
  int n3 = (n / 100) % 10;
  int n4 = (n / 10) % 10;
  int n5 = (n) % 10;
  n = n1 * 10000 + n3 * 1000 + n5 * 100 + n4 * 10 + n2;
  unsigned long long m = n;
  for (int i = 1; i <= 4; i++) n = (n * m) % 100000;
  n1 = (n / 10000);
  n2 = (n / 1000) % 10;
  n3 = (n / 100) % 10;
  n4 = (n / 10) % 10;
  n5 = (n) % 10;
  if (n1 == 0)
    cout << 0;
  else
    cout << n1;
  if (n2 == 0)
    cout << 0;
  else
    cout << n2;
  if (n3 == 0)
    cout << 0;
  else
    cout << n3;
  if (n4 == 0)
    cout << 0;
  else
    cout << n4;
  if (n5 == 0)
    cout << 0;
  else
    cout << n5;
}
