#include <bits/stdc++.h>
long long n, ar[100];
int main() {
  for (int i = 1; i <= 5; i++) scanf("%1I64d", ar + i);
  n = 0;
  n += ar[2];
  n += ar[4] * 10;
  n += ar[5] * 100;
  n += ar[3] * 1000;
  n += ar[1] * 10000;
  long long k = n;
  for (int i = 1; i <= 4; i++) {
    n *= k;
    n %= 100000;
  }
  printf("%05I64d", n);
  return 0;
}
