#include <bits/stdc++.h>
int Max(int n);
int main(void) {
  long n, i, j;
  long long m;
  scanf("%ld", &n);
  m = Max(n);
  j = m;
  for (i = 1; i <= 4; i++) {
    m = m * j;
    m %= 100000;
  }
  if (m == 0) {
    printf("00000\n");
  } else if (m < 10) {
    printf("0000%lld\n", m);
  } else if (m < 100) {
    printf("000%lld\n", m);
  } else if (m < 1000) {
    printf("00%lld\n", m);
  } else if (m < 10000) {
    printf("0%lld\n", m);
  } else {
    printf("%lld\n", m);
  }
}
int Max(int n) {
  int i, j, k, l, m;
  i = n / 10000;
  j = (n / 1000) % 10;
  k = (n / 100) % 10;
  l = (n / 10) % 10;
  m = n % 10;
  return (i * 10000 + k * 1000 + m * 100 + l * 10 + j);
}
