#include <bits/stdc++.h>
using namespace std;
const int a[5] = {1, 3, 5, 4, 2};
char s[10];
int main() {
  scanf("%s", s);
  int ret = 0, ans = 1;
  for (int i = 0; i < 5; i++) ret = ret * 10 + s[a[i] - 1] - '0';
  for (int i = 0; i < 5; i++) ans = (long long)ans * ret % 100000;
  printf("%05d\n", ans);
}
