#include <bits/stdc++.h>
int main() {
  int n;
  long long int s, c;
  scanf("%d", &n);
  s = n / 10000 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 +
      n / 10 % 10 * 10 + n / 1000 % 10;
  c = s;
  for (int i = 1; i < 5; i++) {
    c = c * s;
    c %= 100000;
  }
  printf("%05lld", c);
}
