#include <bits/stdc++.h>
int main() {
  long long int n, i = 4;
  scanf("%lld", &n);
  long long int w[10000];
  while (n != 0) {
    w[i] = n % 10;
    n = n / 10;
    i--;
  }
  long long int s = 0, j = 1, a[5];
  a[0] = w[0];
  a[1] = w[2];
  a[2] = w[4];
  a[3] = w[3];
  a[4] = w[1];
  for (i = 4; i >= 0; i--) {
    s = s + a[i] * j;
    j = j * 10;
  }
  long long int x = 1;
  for (i = 0; i < 5; i++) {
    x = x * s;
    x = x % 100000;
  }
  printf("%05lld", x);
  return 0;
}
