#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    long long int i, j, k = 0, l = 0;
    long double z = 0.0;
    long long int n, m = 0;
    cin >> n;
    long long int a, b, c, d, e;
    c = n % 10;
    n = n / 10;
    d = n % 10;
    n = n / 10;
    b = n % 10;
    n = n / 10;
    e = n % 10;
    n = n / 10;
    a = n % 10;
    n = n / 10;
    k = k + pow(e, 5);
    l = (50 * pow(e, 4) * (a * 1000 + b * 100 + c * 10 + d));
    l = l % 100000;
    k = k + l;
    l = (1000 * pow(e, 3) * (a * 1000 + b * 100 + c * 10 + d) *
         (a * 1000 + b * 100 + c * 10 + d));
    l = l % 100000;
    k = k + l;
    l = (10000 * pow(e, 2) * (a * 1000 + b * 100 + c * 10 + d) *
         (a * 1000 + b * 100 + c * 10 + d) * (a * 1000 + b * 100 + c * 10 + d));
    l = l % 100000;
    k = k + l;
    l = (50000 * pow(e, 1) * pow(d, 4));
    l = l % 100000;
    k = k + l;
    k = k % 100000;
    printf("%05d", k);
  }
}
