The protection of a popular program developed by one of IT City companies is organized the following way. After installation it outputs a random five digit number which should be sent in SMS to a particular phone number. In response an SMS activation code arrives.A young hacker Vasya disassembled the program and found the algorithm that transforms the shown number into the activation code. Note: it is clear that Vasya is a law-abiding hacker, and made it for a noble purpose — to show the developer the imperfection of their protection.The found algorithm looks the following way. At first the digits of the number are shuffled in the following order <first digit><third digit><fifth digit><fourth digit><second digit>. For example the shuffle of 12345 should lead to 13542. On the second stage the number is raised to the fifth power. The result of the shuffle and exponentiation of the number 12345 is 455 422 043 125 550 171 232. The answer is the 5 last digits of this result. For the number 12345 the answer should be 71232.Vasya is going to write a keygen program implementing this algorithm. Can you do the same?

The only line of the input contains a positive integer five digit number for which the activation code should be found.

Output exactly 5 digits without spaces between them — the found activation code of the program.

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Quan
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long a, b, c, d, e;
        a = n % 10;
        n /= 10;
        b = n % 10;
        n /= 10;
        c = n % 10;
        n /= 10;
        d = n % 10;
        n /= 10;
        e = n % 10;
        n /= 10;
        n = 10000 * e + 1000 * c + 100 * a + 10 * b + d;
        //System.out.println((int) Math.pow(n, 5) % 100000);
        long k = n;
        for (int i = 0; i < 4; i++) {
            k = (k * n) % 100000;
        }
        if (k != 0) {
            System.out.println(k);
        } else {
            System.out.println("00000");
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        char [] arr = sc.next().toCharArray();
        char [] arr2 = {arr[0] , arr[2] , arr[4] , arr [3] , arr[1]};
        String arr3 = "";
        for (int i = 0 ; i < 5 ; ++ i) arr3 += arr2[i];
        long num = Long.parseLong(arr3);
        long res = num;
        for (int i = 0 ; i < 4 ; ++ i) res = (res * num) % 100000L;
        String ress = res + "";
        while (ress.length() < 5) ress = "0" + ress;
        System.out.println(ress);
        out.flush();
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}

// "Взлом кода"

import java.io.*;
import java.util.*;

public class Main {
    void solve(Scanner in, PrintWriter out) {
        // given number
        int n = in.nextInt();

        // shuffled number
        long s = n / 10000 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 + n / 10 % 10 * 10 + n / 1000 % 10;

        // fifth power modulo 100000
        int p = (int)(s * s % 100000 * s % 100000 * s % 100000 * s % 100000);

        // print the answer
        out.print("" + p / 10000 + p / 1000 % 10 + p / 100 % 10 + p / 10 % 10 + p % 10);
    }

    void run() {
        try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

    import java.io.*;
    import java.util.*;
    import java.math.*;
    import java.math.BigInteger;
    import java.math.BigDecimal;
    public class ohtry{
        static BigInteger N = new BigInteger("1234567890");
        static BigInteger mod = new BigInteger("1000000007");

        public void run(InputReader reader)throws IOException{
            //System.out.println("Lets test!");
            String s = reader.readString();
            String res = "";
            res = res + s.charAt(0);
            res = res + s.charAt(2);
            res = res + s.charAt(4);
            res = res + s.charAt(3);
            res = res + s.charAt(1);
            BigInteger tmp = new BigInteger(res);
            BigInteger store = tmp;
            for(int i = 1; i < 5; ++i){
                tmp = tmp.multiply(store);
            }
            res = tmp.toString();
            System.out.println(res.substring(res.length() - 5));
        }

        public static void solve(BigInteger S, BigInteger a , BigInteger b){
            String s = S.toString();
            boolean NotPossible = s.charAt(0)=='0';
            if(NotPossible){
                System.out.println("NO");
                return;
            }
            int go = s.length();
            String cur = "";
            boolean possible = false;
            String left = "", right = "";
            for(int i = 0; i < go - 1; ++i){
                cur = cur + s.charAt(i);
                if(s.charAt(i+1) != '0'){
                    String next = s.substring(i+1);
                    if(divides(new BigInteger(cur) , a) && divides(new BigInteger(next) , b) ){
                        possible = true;
                        left = cur;
                        right = next;
                        break;
                    }
                }
            }
            if(possible)
            System.out.println("YES\n" + left + "\n" + right);
            else
            System.out.println("NO");
        return;
    }

    public static boolean divides(BigInteger x , BigInteger y){
        if(x.compareTo(y)==0) return true;
        if(x.compareTo(y) < 0) return false;
        String u = x.toString();
        String v = y.toString();
        long cur = 0;
        long rem = 0;
        long b = y.longValue();
        for(int i = 0; i < u.length(); ++i){
            cur = cur * 10 + (u.charAt(i) - '0');
            cur = cur % b;
    }
    return cur==0;
}

        public static void main(String args[])throws IOException{
         InputReader reader = new InputReader(System.in);
         ohtry letstry = new ohtry();
         letstry.run(reader);
        }
        static final class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() throws IOException {
            if (curChar >= numChars) {
                curChar = 0;
                numChars = stream.read(buf);
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public final int readInt() throws IOException {
            return (int)readLong();
        }

        public final long readLong() throws IOException {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
                if (c == -1) throw new IOException();
            }
            boolean negative = false;
            if (c == '-') {
                negative = true;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return negative ? -res : res;
        }

        public final int[] readIntArray(int size) throws IOException {
            int[] array = new int[size];
            for (int i=0; i<size; i++) {
                array[i] = readInt();
            }
            return array;
        }

        public final long[] readLongArray(int size) throws IOException {
            long[] array = new long[size];
            for (int i=0; i<size; i++) {
                array[i] = readLong();
            }
            return array;
        }

        public final String readString() throws IOException {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.append((char)c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
    }

import java.util.Scanner;
public class Code{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
      int d1 = n / 10000;
      int d2 = n / 1000 % 10;
      int d3 = n / 100 % 10;
      int d4 = n / 10 % 10;
      int d5 = n % 10;
      long p = d1*10000+d3*1000+d5*100+d4*10+d2;
      final int c = 100000;
      int r = (int)(p * p % c * p % c * p % c * p % c);
      int rd1 = r / 10000;
      int rd2 = r / 1000 % 10;
      int rd3 = r / 100 % 10;
      int rd4 = r / 10 % 10;
      int rd5 = r % 10;
      System.out.println("" + rd1 + rd2 + rd3 + rd4 + rd5);
   }
}

import java.util.Scanner;

public class CrackingTheCode {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int arr[]=new int [5];
		for(int i=4;i>=0;i--)
		{
			int rem1=n%10;
			arr[i]=rem1;
			n/=10;
		}
		int num=0;
		for(int i=0;i<5;i++)
		{
			if(i%2==0){
				num=num*10+arr[i];
			}
		}
		for(int i=4;i>=0;i--)
		{
			if(i%2!=0){
				num=num*10+arr[i];
			}
		}
		long rem=num%100000;
		rem=(rem*num)%100000;
		rem=(rem*num)%100000;
		rem=(rem*num)%100000;
		rem=(rem*num)%100000;
		int output[]=new int[5];
		for(int i=4;i>=0;i--)
		{
			int rem1=(int) (rem%10);
			output[i]=rem1;
			rem/=10;
		}
		for(int i=0;i<5;i++)
		{
			System.out.print(output[i]);
		}
	}
}

import java.util.*;
import java.math.*;

public class Main{

    public static String changeCharInPosition(int position, char ch, String str){
        char[] charArray = str.toCharArray();
        charArray[position] = ch;
        return new String(charArray);
    }

    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String n = scan.next();

        char tmp = n.charAt(1);
        n = changeCharInPosition(1, n.charAt(2), n);
        n = changeCharInPosition(2, tmp, n);

        tmp = n.charAt(2);
        n = changeCharInPosition(2, n.charAt(4), n);
        n = changeCharInPosition(4, tmp, n);

        BigInteger resp = new BigInteger(n);
        BigInteger md = new BigInteger("100000");
        resp = resp.pow(5);
        System.out.println(String.format("%05d", Integer.parseInt(resp.mod(md).toString())));
    }
}

import java.util.Scanner;

public class Problem {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        // Получаем число xxxxx и разбиваем на цифры
        long n = in.nextLong();
        long n1 = n / 10000;
        long n2 = (n / 1000) % 10;
        long n3 = (n / 100) % 10;
        long n4 = (n / 10) % 10;
        long n5 = n % 10;
        // Перемешанное число
        n = n1 * 10000 + n3 * 1000 + n5 * 100 + n4 * 10 + n2;

        final int MOD = 100000;
        // n^5 не помещается в long
        // Ищем последние 5 цифр числа
        long a = (((n * n % MOD) * n % MOD) * n % MOD) * n % MOD;
        // Выводим пароль, состоящий из 5 цифр, включая нули
        System.out.printf("%05d", a);
        System.out.println();
    }
}

import java.util.Scanner;

public class Problem {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        // Получаем число xxxxx и разбиваем на цифры
        long n = in.nextLong();
        long n1 = n / 10000;
        long n2 = (n / 1000) % 10;
        long n3 = (n / 100) % 10;
        long n4 = (n / 10) % 10;
        long n5 = n % 10;
        // Перемешанное число
        n = n1 * 10000 + n3 * 1000 + n5 * 100 + n4 * 10 + n2;

        final int MOD = 100000;
        // n^5 не помещается в long
        // Ищем последние 5 цифр каждого возведения в степень
        long a = (((n * n % MOD) * n % MOD) * n % MOD) * n % MOD;
        // Разбиваем на цифры, т.к может быть число 00034
        long a1 = a / 10000;
        long a2 = (a / 1000) % 10;
        long a3 = (a / 100) % 10;
        long a4 = (a / 10) % 10;
        long a5 = a % 10;
        // Выводим пароль, состоящий из 5 цифр
        System.out.println(a1 + "" + a2 + "" + a3 + "" + a4 + "" + a5);
    }
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int n1 = n / 10000;
		int n2 = n / 1000 % 10;
		int n3 = n / 100 % 10;
		int n4 = n / 10 % 10;
		int n5 = n % 10;
		long res = n1 * 10000 + n3 * 1000 + n5 * 100 + n4 * 10 + n2;
		final int mod = 100000;
		int r = (int) (res * res % mod * res % mod * res % mod * res % mod);
		int r1 = r / 10000;
		int r2 = r / 1000 % 10;
		int r3 = r / 100 % 10;
		int r4 = r / 10 % 10;
		int r5 = r % 10;
		out.println("" + r1 + r2 + r3 + r4 + r5);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

public class Main
{
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt();
    int m = n / 10000;
    m = m * 10 + (n / 100) % 10;
    m = m * 10 + n % 10;
    m = m * 10 + (n / 10) % 10;
    m = m * 10 + (n / 1000) % 10;
	//System.out.println(m);
    BigInteger f = BigInteger.ONE;
    for (int i = 1; i <= 5; i++) {
      f = f.multiply(BigInteger.valueOf(m));
    }
    BigInteger WHAT = BigInteger.valueOf(100000);
    f = f.mod(WHAT);
    if (f.compareTo(BigInteger.valueOf(10)) == -1) System.out.print(0);
    if (f.compareTo(BigInteger.valueOf(100)) == -1) System.out.print(0);
    if (f.compareTo(BigInteger.valueOf(1000)) == -1) System.out.print(0);
    if (f.compareTo(BigInteger.valueOf(10000)) == -1) System.out.print(0);
    System.out.println(f.toString());
    out.close();
  }
}

import java.util.*;
import java.io.*;

/*
* 0000
* 0000
* 0000
* 0000
* */

public class Main {

    public void run(){
        try(
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out);
                )
        {
            solve(in,out);
        }
    }

    public void solve(Scanner sc, PrintWriter out){
        String str = sc.nextLine();
        StringBuilder sb = new StringBuilder();
        sb.append(str.charAt(0));
        sb.append(str.charAt(2));
        sb.append(str.charAt(4));
        sb.append(str.charAt(3));
        sb.append(str.charAt(1));
        long N = Long.parseLong(sb.toString());
        int p = 100000;
      //  System.out.printf("%05d",((tempN%100000)*(N%100000))%100000);
        long res = (((((N*N)%p*N)%p*N)%p*N)%p);
        System.out.printf("%05d",(((((N*N)%p*N)%p*N)%p*N)%p));
        }

    public static void main(String[] args) {
	// write your code here
        new Main().run();
    }
}

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String args[]) throws IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            long k = (n/10000)*10000 + ((n%1000)/100) * 1000 + (n%10) * 100 + ((n%100) / 10) * 10 + ((n / 1000) % 10);
            long res = k;
            for (int i = 1; i < 5; i++) {
                res *= k;
                res %= 100000;
            }
            out.format("%05d", res);
        }

    }

    static class InputReader {

        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String s;
		s = sc.next();
		//System.out.println(s);
		char[] t = s.toCharArray();
		char[] w = s.toCharArray();
		t [ 1 ] = w [ 2 ];
		t [ 2 ] = w [ 4 ];
		t [ 3 ] = w [ 3 ];
		t [ 4 ] = w [ 1 ];
		String q = new String ( t );
		BigInteger b = new BigInteger(q);
		b = b.pow(5);
		b = b.mod(new BigInteger("100000"));
		int bb = b.intValue();
		if ( bb < 10 )
			System.out.print("0000");
		else if ( bb < 100 )
			System.out.print("000");
		else if ( bb < 1000 )
			System.out.print("00");
		else if ( bb < 10000 )
			System.out.println("0");
		System.out.println(bb);
	}
}

/* Author: Sagdat Kozhakhmetov
 * Date: 5 марта 2016 г.
 * Problem: Cracking code
 */

import java.io.*;
import java.util.*;

public class Main {
	void solve(Scanner in, PrintWriter out) {
		int N = in.nextInt();
		int N1 = N/10000;
		int N2 = N/1000%10;
		int N3 = N/100%10;
		int N4 = N/10%10;
		int N5 = N%10;

		long M = N1*10000 + N3*1000 + N5*100 + N4*10 + N2;

		long R = M*M%100000;
		R = R*M%100000;
		R = R*M%100000;
		R = R*M%100000;

		out.printf("%05d\n", R);
	}

	void run() {
		Locale.setDefault(Locale.US);

		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out);) {
			solve(in, out);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

import java.math.BigInteger;
import java.util.Scanner;

public class Equation {
    static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args){

        int inp = scanner.nextInt();
        String inp2 = Integer.toString(inp);
        inp2 = new String(new char[]{inp2.charAt(0), inp2.charAt(2), inp2.charAt(4), inp2.charAt(3), inp2.charAt(1)});
        BigInteger inp3 = new BigInteger(inp2);

        inp3 = inp3.pow(5);
        String inp4 = inp3.toString();
        inp4 = inp4.substring(inp4.length()-5);
        System.out.println(inp4);
    }
}

import java.io.*;
import java.util.*;
public class Main{
  void solve(Scanner in, PrintWriter out){
    int n = in.nextInt();
    int d1 = n / 10000;
    int d2 = n / 1000 % 10;
    int d3 = n / 100 % 10;
    int d4 = n / 10 % 10;
    int d5 = n % 10;
    long p = d1 * 10000 + d3 * 1000 + d5 * 100 +d4*10 + d2;
    final int MOD = 100000;
    int r =(int) (p*p%MOD*p%MOD*p%MOD*p%MOD);
    // (a * b) % p = ((a%p)*(b%p))%p и надо учесть, что м б ведущие 0
    int rd1 = r / 10000;
    int rd2 = r / 1000 % 10;
    int rd3 = r / 100 % 10;
    int rd4 = r / 10 % 10;
    int rd5 = r % 10;
    out.println(""+rd1+rd2+rd3+rd4+rd5);
  }
  void run(){
    try(
      Scanner in = new Scanner (System.in);
      PrintWriter out = new PrintWriter(System.out)){
        solve(in, out);
    }
  }
  public static void main(String args[]){
    new Main().run();
  }
}

import java.util.*;
import java.io.*;
public class CodeCracking
{

	/************************ SOLUTION STARTS HERE ************************/

	//DONT FORGET TO COMMIT AND PUSH TO GITHUB
	static long mod = (long)1e5;
	private static long modPow(long a,long b)   /* Modular exponentiation  */
	{
		if(b == 0L || a == 1L)
			return 1L;
		else if(b == 1L)
			return a;
		else
		{
			if((b & 1L) == 0L)  		//Checking whether b is even (fast)
				return modPow((a * a) % mod,b / 2L);
			else
				return (a * modPow((a * a) % mod,((b - 1L) / 2L))) % mod ;
		}
	}
	private static void solve(FastScanner s1, FastWriter out){

		char in[] = s1.nextLine().toCharArray();
		char num[] = new char[5];
		num[0] = in[0];
		num[1] = in[2];
		num[2] = in[4];
		num[3] = in[3];
		num[4] = in[1];
		long n = Long.parseLong(new String(num));
		long ans = modPow(n, 5L)%mod ;
		out.print(String.format("%05d", ans));   //Learnt a new concept (%05d)
	}
//36551
	/************************ SOLUTION ENDS HERE ************************/

	/************************ TEMPLATE STARTS HERE ************************/

	public static void main(String []args) throws IOException {
		FastScanner in  = new FastScanner(System.in);
		FastWriter  out = new FastWriter(System.out);
		solve(in, out);
		in.close();
		out.close();
	}

	static class FastScanner{
		public BufferedReader reader;
		public StringTokenizer st;
		public FastScanner(InputStream stream){
			reader = new BufferedReader(new InputStreamReader(stream));
			st = null;
		}
		public String next(){
			while(st == null || !st.hasMoreTokens()){
				try{
					String line = reader.readLine();
					if(line == null) return null;
					st = new StringTokenizer(line);
				}catch (Exception e){
					throw (new RuntimeException());
				}
			}
			return st.nextToken();
		}
		public String nextLine(){
			String str = null;
			try {
				str = reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}
		public void close(){
			try{ reader.close(); } catch(IOException e){e.printStackTrace();}
		}
	}
	static class FastWriter{
		BufferedWriter writer;
		public FastWriter(OutputStream stream){
			writer = new BufferedWriter(new OutputStreamWriter(stream));
		}
		public void print(int i) {
			print(Integer.toString(i));
		}
		public void println(int i) {
			print(Integer.toString(i));
			print('\n');
		}
		public void print(long i) {
			print(Long.toString(i));
		}
		public void println(long i) {
			print(Long.toString(i));
			print('\n');
		}
		public void print(double i) {
			print(Double.toString(i));
		}
		public void print(boolean i) {
			print(Boolean.toString(i));
		}
		public void print(Object o){
			print(o.toString());
		}
		public void println(Object o){
			print(o.toString());
			print('\n');
		}
		public void print(char i) {
			try{writer.write(i);} catch(IOException e){e.printStackTrace();}
		}
		public void print(String s){
			try{writer.write(s);} catch(IOException e){e.printStackTrace();}
		}
		public void println(String s){
			try{writer.write(s);writer.write('\n');} catch(IOException e){e.printStackTrace();}
		}
		public void println(){
			try{writer.write('\n');} catch(IOException e){e.printStackTrace();}
		}
		public void print(int arr[])
		{
			for (int i = 0; i < arr.length; i++) {
				print(arr[i]);
				print(' ');
			}
		}
		public void close(){
			try{writer.close();} catch(IOException e){e.printStackTrace();}
		}
	}

	/************************ TEMPLATE ENDS HERE ************************/
}

import java.util.Scanner;

public class fi {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int a[]=new int [5];
	int g=0;
	while(n!=0)
	{
		a[g]=n%10;
		n=n/10;
		g++;
	}
	long m=a[4]*10000+a[2]*1000+a[0]*100+a[1]*10+a[3];
	//System.out.println(m);
	long j=m;
	for(int i=0;i<4;i++)
	{
	long	t=m*j;
	//System.out.println(t);
	j=0;
		for(int k=0;k<5;k++)
		{
			int u=(int) (t%10);
			t=t/10;
			j=j+(int)(Math.pow(10,k))*u;
		}
	}
	if(j<10)
		System.out.println("0000"+j);
	else

	System.out.println(j);
	}
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int a = in.nextInt();
		int c = (a / 10000) * 10000 + (a / 100) % 10 * 1000 + (a % 10) * 100 + (a / 10) % 10 * 10 + (a / 1000) % 10;
		long ans = c;
		for (int i = 0; i < 4; i++)
			ans = (ans * c) % 100000;
		if (ans < 10000)
			out.print(0);
		if (ans < 1000)
			out.print(0);
		if (ans < 100)
			out.print(0);
		if (ans < 10)
			out.print(0);
		out.print(ans);

	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)
		// Scanner in = new Scanner(new FileReader("input.txt"));
		// PrintWriter out = new PrintWriter(new FileWriter("output.txt"))
		) {

			solve(in, out);
		}
		/*
		 * catch (IOException e) { throw new Error(e); }
		 */
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
public class Cracking_the_Code
{
	public static void main(String ar[])throws IOException
	{
		long n,sqr,k,ct=0,u;
		long a[]=new long[5];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n=Long.parseLong(br.readLine());
		for(int i=0;i<5;i++)
		{
			u=(long)Math.pow(10,4-i);
			a[i]=n/u;
			n%=u;
		}
		k=10000*a[0]+1000*a[2]+100*a[4]+10*a[3]+a[1];
		n=k;
		//System.out.println(k);
		while(ct<4)
		{
			sqr=n*k;
			k=sqr%100000;
			ct++;
		}
		if(k!=0)
		{
			int length = (int)(Math.log10(k)+1);
			System.out.print(k);
			for(int i=length;i<5;i++)
				System.out.print("0");
			System.out.println();
		}
		else
			System.out.println("00000");

	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class code {
	public static void main(String[] args) {
		Scanner kboard = new Scanner(System.in);
		String s = kboard.nextLine();
		String n = s.substring(0, 1) + s.charAt(2) + s.charAt(4) + s.charAt(3) + s.charAt(1);
		long a = Integer.parseInt(n);
		BigInteger b = BigInteger.valueOf(a);
		b = b.pow(5);
		String m = b.toString();
		System.out.println(m.substring(m.length() - 5));
	}
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int d1 = n / 10000;
		int d2 = n / 1000 % 10;
		int d3 = n / 100 % 10;
		int d4 = n / 10 % 10;
		int d5 = n % 10;

		int d = (((d1 * 10 + d3) * 10 + d5) * 10 + d4) * 10 + d2;
		int r = 1;
		for (int i = 0; i < 5; i++) {
			r = (int) ((long) r * d % 100000);
		}

		int r1 = r / 10000;
		int r2 = r / 1000 % 10;
		int r3 = r / 100 % 10;
		int r4 = r / 10 % 10;
		int r5 = r % 10;

		out.println("" + r1 + r2 + r3 + r4 + r5);
	}

	void run() {
		try (
				Scanner in = new Scanner (System.in);
				PrintWriter out = new PrintWriter(System.out);
//				Scanner in = new Scanner(new FileReader("input.txt"));
//				PrintWriter out = new PrintWriter(new FileWriter("output.txt"));

		) {
			solve(in, out);
		}
//		catch (IOException e) {
//			throw new Error(e);
//		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String alt = "";
        alt+=s.charAt(0);
        alt+=s.charAt(2);
        alt+=s.charAt(4);
        alt+=s.charAt(3);
        alt+=s.charAt(1);
        BigInteger a = new BigInteger(alt), b = a;
        for(int i = 0; i < 4; i++)
        {
        	a = a.multiply(b);
        }
        String ans = a.toString(), res = "";
        for(int i = ans.length() - 1; i > ans.length() - 6; i--)
        {
        	res+=ans.charAt(i);
        }
        for(int i = res.length() - 1; i >= 0; i--)
        {
        	System.out.print(res.charAt(i));
        }
    }
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;
/*
3
24

4
132
 */
public class a
{
	public static void main(String[] arg) throws IOException
	{
		new a();
	}
	public a() throws IOException
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		String s = in.next();
		String n = ""+s.charAt(0)+s.charAt(2)+s.charAt(4)+s.charAt(3)+s.charAt(1);
		String ans= String.valueOf(pow(Integer.parseInt(n), 5));
		while(ans.length() < 5) ans = '0'+ans;
		out.println(ans);
		in.close(); out.close();
	}

	public long pow(long base, long exp)
	{
		if(exp == 0) return 1;
		if((exp&1) == 1) return base*pow(base, exp-1)%100000;
		long ret = pow(base, exp/2)%100000;
		return ret*ret%100000;
	}
	public long choose(long n, long k)
	{
		if(k == 0)
			return 1;
		return choose(n, k-1)*(n-k+1)/k;
	}
	long gcd(long a, long b)
	{
		return b == 0 ? a:gcd(b, a%b);
	}
	class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public void close() throws IOException
		{
			br.close();
		}
	}
}

import java.util.*;
import java.math.*;
public class a
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String te=s.charAt(0)+""+s.charAt(2)+s.charAt(4)+s.charAt(3)+s.charAt(1);
    BigInteger ans=new BigInteger(te);
     ans=ans.pow(5);
    String gh=ans.toString();
    System.out.println(gh.substring(gh.length()-5,gh.length()));
  }
  //so hard much wow
}

import java.math.BigInteger;
import java.util.Scanner;

/**
 * Created by Delux on 20/07/2016.
 */
public class Main {
    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        String num;
        char x[]=new char[5];
        num=cin.next();
        for(int i=0;i<5;i++)
        {
            x[i]=num.charAt(i);
        }
        char t=x[1];
        x[1]=x[2];
        x[2]=t;
        x[2]=t;
        x[2]=x[4];
        x[4]=t;
        int m=0;
        for(int i=0;i<5;i++)
        {
            m=m*10+(x[i]-'0');
        }
       // System.out.println(m);
        BigInteger c=new BigInteger(BigInteger.valueOf(m)+"");
        c=c.pow(5);
        String cade=c.toString();
        System.out.println(cade.substring(cade.length()-5));
    }
}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {
        int num = in.nextInt();
        int d1 = num / 10000;
        int d2 = num / 1000 % 10;
        int d3 = num / 100 % 10;
        int d4 = num / 10 % 10;
        int d5 = num % 10;
        int shuffle = 10000 * d1 + 1000 * d3 + 100 * d5 + 10 * d4 + d2;
        int c = modular(shuffle, 5, 100000);
        int cd1 = c / 10000;
        int cd2 = c / 1000 % 10;
        int cd3 = c / 100 % 10;
        int cd4 = c / 10 % 10;
        int cd5 = c % 10;
        out.println("" + cd1 + cd2 + cd3 + cd4 + cd5);
    }

    int modular(int a, int n, int m) {
        if (n == 0)
            return 1;
        else {
            int n2 = n / 2;
            long result = modular(a, n2, m);
            result = (result * result) % m;
            if (n % 2 == 1)
                result = (result * a) % m;
            return (int)result;
        }
    }

    void run() {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

import java.io.*;
import java.util.Scanner;

/**
 *
 * @author RIG
 */
public class AppPro {
    void solve(Scanner in,PrintWriter out){
    int n = in.nextInt();
    int i = n/10000;
    int ii = n/1000%10;
    int iii = n/100%10;
    int iv = n/10%10;
    int v = n%10;
    long p = i*10000 + iii *1000 + v*100 + iv*10 + ii;
    final int MOD = 100000;
    int r = (int) (p*p%MOD*p%MOD*p%MOD*p%MOD);
    int r_i = r/10000;
    int r_ii = r/1000%10;
    int r_iii = r/100%10;
    int r_iv = r/10%10;
    int r_v = r%10;
    out.println("" + r_i + r_ii + r_iii + r_iv + r_v);
    }
    void run(){
        try ( Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);)
            {
                solve(in,out);
            }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new AppPro().run();
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;
import java.math.*;
import java.io.*;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;

/**
 *
 * @author magzhankairanbay
 */
public class Main {

    public static BigInteger binomial(int N, int K) {
        BigInteger ret = BigInteger.ONE;
        for (int k = 0; k < K; k++) {
            ret = ret.multiply(BigInteger.valueOf(N-k))
                     .divide(BigInteger.valueOf(k+1));
        }
        return ret;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try {

            Scanner in = new Scanner(System.in);

            String s = in.next();
            String p = s.charAt(0) + "" + s.charAt(2) + "" + s.charAt(4) + "" + s.charAt(3) + "" + s.charAt(1);
            BigInteger b = new BigInteger(p);
            BigInteger r = b.pow(5);
            String h = r.toString();
            System.out.println(h.substring(h.length() - 5));

        } catch(Exception ex) {

            System.out.println(ex.toString());
        }
    }

}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class L_Volbit {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int[]per = {0,2,4,3,1};
        char[] line = in.next().toCharArray();
        char[]cur = new char[5];
        for(int i = 0; i < 5; i++){
            cur[i] = line[per[i]];
        }
        long v = Long.parseLong(new String(cur));
        BigInteger result = BigInteger.valueOf(v).pow(5).mod(BigInteger.valueOf(100000));
        if(result.toString().length() < 5){
            for(int i = 0; i + result.toString().length() < 5; i++){
                out.print(0);
            }
        }
        out.println(result);
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return (val * val) % MOD;
        } else {
            return (val * ((val * a) % MOD)) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;

public class main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] p = {0, 4, 1, 3, 2};

    public static void main(String[] args) throws Exception{
        String s = br.readLine();

        char[] a = new char[5];
        for(int i = 0; i < 5; i++){
            a[p[i]] = s.charAt(i);
        }
        int N = 0;
        for(int i = 0; i < 5; i++){
            N += (a[i]-'0') * Math.pow(10, 5-i-1);
        }
        // pw.print(N + "\n");
        long total = 1;
        // pw.print(BigInteger.valueOf(N).pow(5) + "\n");
        for(int i = 0; i < 5; i++){
            total = (total * N) % 100000;
        }
        pw.format("%05d\n", total);
        pw.close();
        br.close();
    }
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int x = in.nextInt();
		int a = x / 10000;
		int b = x / 1000 % 10;
		int c = x / 100 % 10;
		int d = x / 10 % 10;
		int e = x % 10;
		long y = a * 10000 + c * 1000 + e * 100 + d * 10 + b;
		long res = y * y % 100000 * y % 100000 * y % 100000 * y % 100000;
		if (res == 0) {
			out.println("00000");
		} else {
			out.println(res);
		}

	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {

			solve(in, out);
		} /*
			 * catch (IOException e) { throw new Error(e); }
			 */

	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
import java.util.*;

public class Main {

	void solve (Scanner in, PrintWriter out) {
		long n = in.nextLong();
		long number1, number2, number3, number4, number5, cod;
		long number1_1, number2_2, number3_3, number4_4, number5_5, cod2, a, b;

		number1 = n / 10000;
		number2 = (n / 100) % 10;
		number3 = n % 10;
		number4 = (n / 10) % 10;
		number5 = (n / 1000) % 10;

		cod = number1 * 10000 + number2 * 1000 + number3 * 100 + number4 * 10 + number5;

		a = cod * cod * cod;
		b = cod * cod;

		cod2 = ((a % 100000) * (b % 100000)) % 100000;

		number1_1 =((a % 10) * (b % 10)) % 10;
		number2_2 = (((a % 100) * (b % 100)) % 100) / 10;
		number3_3 = (((a % 1000) * (b % 1000)) % 1000) / 100;
		number4_4 = (((a % 10000) * (b % 10000)) % 10000) / 1000;
		number5_5 = (((a % 100000) * (b % 100000)) % 100000) / 10000;

		out.println(number5_5 + "" + number4_4 + "" + number3_3 + "" + number2_2 + "" + number1_1);

	}

	void run() {
	     try (
				Scanner in = new Scanner(System.in);
				PrintWriter out = new PrintWriter(System.out)){

	    	 solve (in, out);
	     }
	}

	public static void main(String args[]) {
		new Main().run();
    }
}

import java.io.*;
import java.util.*;

public class Main {

	private void solve(Scanner in, PrintWriter out) {
		long n = in.nextLong();
		n = n / 10000 % 10 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 + n / 10 % 10 * 10 + n / 1000 % 10;
		long r = n;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		String s = "" + r;
		s = "00000".substring(0, 5 - s.length()) + s;
		out.println(s);
	}

	private void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class Equation {
    static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args){

        int inp = scanner.nextInt();
        String inp2 = Integer.toString(inp);
        inp2 = new String(new char[]{inp2.charAt(0), inp2.charAt(2), inp2.charAt(4), inp2.charAt(3), inp2.charAt(1)});
        BigInteger inp3 = new BigInteger(inp2);

        inp3 = inp3.pow(5);
        String inp4 = inp3.toString();
        inp4 = inp4.substring(inp4.length()-5);
        System.out.println(inp4);
    }
}

import java.io.*;
import java.util.*;
import java.util.stream.IntStream;

public class B implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new B().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int gcd(int a, int b) {
        return a == 0 ? b : gcd(b % a, a);
    }

    int lcm(int a, int b) {
        return a / gcd(a, b) * b;
    }

    private void solve() {
        char[] s = readString().toCharArray();
        char[] t = new char[s.length];
        t[0] = s[0];
        t[1] = s[2];
        t[2] = s[4];
        t[3] = s[3];
        t[4] = s[1];
        long v = Long.parseLong(new String(t));
        long res = 1;
        for (int i = 0; i < 5; i++) {
            res = (res * v) % 100000;
        }
        String ans = String.valueOf(res);
        while (ans.length() < 5) {
            ans = "0" + ans;
        }
        out.println(ans);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class C {

    public static void main(String[] args) throws Exception {

	// TODO Auto-generated method stub
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
	StringTokenizer st = new StringTokenizer(bf.readLine());
	char[] n = (st.nextToken()).toCharArray();
	int [] s = {n[0]-'0',(n[2])-'0',(n[4])-'0',(n[3])-'0',(n[1])-'0'};
	long n2 = s[0]*10000+s[1]*1000+s[2]*100+s[3]*10+s[4];
	out.printf("%05d",(((((n2*n2)%100000)*n2)%100000*n2)%100000*n2)%100000);
	out.flush();
	out.close();
    }
}

import java.util.Scanner;

public class Problem {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        // Получаем число xxxxx и разбиваем на цифры
        long n = in.nextLong();
        long n1 = n / 10000;
        long n2 = (n / 1000) % 10;
        long n3 = (n / 100) % 10;
        long n4 = (n / 10) % 10;
        long n5 = n % 10;
        // Перемешанное число
        n = n1 * 10000 + n3 * 1000 + n5 * 100 + n4 * 10 + n2;

        final int MOD = 100000;
        // n^5 не помещается в long
        // Ищем последние 5 цифр каждого возведения в степень
        long a = (((n * n % MOD) * n % MOD) * n % MOD) * n % MOD;
        // Разбиваем на цифры, т.к может быть число 00034
        long a1 = a / 10000;
        long a2 = (a / 1000) % 10;
        long a3 = (a / 100) % 10;
        long a4 = (a / 10) % 10;
        long a5 = a % 10;
        // Выводим пароль, состоящий из 5 цифр
        System.out.println(a1 + "" + a2 + "" + a3 + "" + a4 + "" + a5);
    }
}

//package codeforce;

import java.math.BigInteger;
import java.util.Scanner;

/* @author Kbk*/
public class CrackingTheCode {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String num=sc.next();
        String num2="";
        num2=num2+num.charAt(0)+num.charAt(2)+num.charAt(4)+num.charAt(3)+num.charAt(1);
        BigInteger b=new BigInteger(""+num2);
        b=b.pow(5);
        b=b.mod(b.valueOf(100000));
        String temp=""+b;
        if(temp.length()>=5)
            System.out.println(temp);
        else if(temp.length()<5){
            for(int i=5-temp.length();i>0;i--){
                temp='0'+temp;
            }
            System.out.println(temp);
        }
    }
}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {
        long num = in.nextLong();
        long d1 = num / 10000;
        long d2 = num / 1000 % 10;
        long d3 = num / 100 % 10;
        long d4 = num / 10 % 10;
        long d5 = num % 10;
        num = 10000 * d1 + 1000 * d3 + 100 * d5 + 10 * d4 + d2;
        num = modular(num, 5, 100000);
        if(num < 10)
            out.println("0000" + num);
        else if (num < 100)
            out.println("000" + num);
        else if (num < 1000)
            out.println("00"+ num);
        else if (num < 10000)
            out.println("0" + num);
        else
            out.println(num);
    }

    long modular(long a, long n, long m) {
        if (n == 0)
            return 1;
        else {
            long n2 = n / 2;
            long result = modular(a, n2, m);
            result = (result * result) % m;
            if (n % 2 == 1)
                result = (result * a) % m;
            return result;
        }
    }

    void run() {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

import java.io.*;
import java.util.*;
/**
 *
 * @author Sourav Kumar Paul
 */
public class SolveL {
    public static void main(String[] args) throws IOException{
        Reader in = new Reader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        char nos[] = in.nextLine().toCharArray();
        long num = 0;
        num= (nos[0]-'0')*10000+(nos[2]-'0')*1000+(nos[4]-'0')*100+(nos[3]-'0')*10+(nos[1]-'0');
        out.printf("%05d",modPow(num,5,100000));
        //out.println(num);
        out.flush();
        out.close();
    }
    private static long modPow(long base, long exp, long mod) {

        base = base % mod;
        long result =1l;
        while(exp > 0)
        {
            if(exp % 2== 1)
            {
                result = (result * base) % mod;
                exp --;
            }
            else
            {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;

    }
    public static class Reader {
        public BufferedReader reader;
        public StringTokenizer st;

        public Reader(InputStreamReader stream) {
            reader = new BufferedReader(stream);
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public String nextLine() throws IOException{
            return reader.readLine();
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }

    }
}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {
        int n=in.nextInt();
        int d1=n/10000;
        int d2=n/1000%10;
        int d3=n/100%10;
        int d4=n/10%10;
        int d5=n%10;
        long p=d1*10000+d3*1000+d5*100+d4*10+d2;
        final int MOD=100000;
        int r=(int)(p*p%MOD*p%MOD*p%MOD*p%MOD);
        int rd1=r/10000;
        int rd2=r/1000%10;
        int rd3=r/100%10;
        int rd4=r/10%10;
        int rd5=r%10;
        out.println(""+rd1+rd2+rd3+rd4+rd5);
    }

    void run() {
        try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out);) {
            solve(in, out);
        }
    }

    public static void main(String args[]) {
        new Main().run();
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class A {
public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 String s=sc.next();
	 char []a=s.toCharArray();
	 s="";
	 s=""+a[0]+a[2]+a[4]+a[3]+a[1];
	 BigInteger n=new BigInteger(s);
	 n=n.pow(5);
//	 System.out.println(n);
	 System.out.println((""+n).substring((""+n).length()-5,(""+n).length()));

}
}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.io.PrintWriter;
import java.io.OutputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Alex
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskL solver = new TaskL();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskL {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
//        int n = in.readInt();
            char[] a = in.next().toCharArray();
            String s = String.valueOf(a[0]) +
                    String.valueOf(a[2]) +
                    String.valueOf(a[4]) +
                    String.valueOf(a[3]) +
                    String.valueOf(a[1]);
//        out.printLine(s);
            int shuff = Integer.parseInt(s);
//        int shuff = g(a[0]) * 10000 +
//                g(a[2]) * 1000 +
//                g(a[4]) * 100 +
//                g(a[3]) * 10 +
//                g(a[1]);
            BigInteger pow = BigInteger.valueOf(shuff).pow(5);
            String res = pow.toString();
            out.printLine(res.substring(res.length() - 5));
//        out.printLine(IntegerUtils.power(shuff, 5, 100000));
//        out.printLine(pow);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if(numChars == -1)
                throw new InputMismatchException();
            if(curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch(IOException e) {
                    throw new InputMismatchException();
                }
                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while(isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                if(Character.isValidCodePoint(c))
                    res.appendCodePoint(c);
                c = read();
            } while(!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if(filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for(int i = 0; i < objects.length; i++) {
                if(i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

import java.util.*;
import java.lang.*;
public class p630n{
	public static void main(String []args){
		Scanner s=new Scanner(System.in);
		int  i=s.nextInt();
		int a5=(i%10)*100,a4=((i/10)%10)*10,a3=((i/100)%10)*1000,a2=((i/1000)%10),a1=((i/10000)%10)*10000;
		a1+=a2+a3+a4+a5;
		long x=a1;
		int h=4;
		while(h-->0){
			x*=a1;
			x%=100000;
		}
		int t=(int)x,j;
		for(j=5;j>0;j--)
			if((t=t/10)==0)
				break;
			//j-=5;
			j--;
			while(j-->0)
				System.out.print("0");
		System.out.println(x);

	}
}

import java.math.BigInteger;
import java.util.Scanner;

/**
 * Created by Delux on 20/07/2016.
 */
public class Main {
    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        String num;
        char x[]=new char[5];
        num=cin.next();
        for(int i=0;i<5;i++)
        {
            x[i]=num.charAt(i);
        }
        char t=x[1];
        x[1]=x[2];
        x[2]=t;
        x[2]=t;
        x[2]=x[4];
        x[4]=t;
        int m=0;
        for(int i=0;i<5;i++)
        {
            m=m*10+(x[i]-'0');
        }
       // System.out.println(m);
        BigInteger c=new BigInteger(BigInteger.valueOf(m)+"");
        c=c.pow(5);
        String cade=c.toString();
        System.out.println(cade.substring(cade.length()-5));
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class CrackingTheCode {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		String s = "" + c[0] + c[2] + c[4] + c[3] + c[1];
		BigInteger b = new BigInteger(s);
		b = b.pow(5);
		b = b.mod(BigInteger.valueOf(100000));
		int ans = b.intValue();
		int zeros = 5 - (ans+"").length();
		String res = ""+ans;
		for (int i = 0; i < zeros; i++)
			res = '0' + res;
		System.out.println(res);
		sc.close();
	}
}

import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.math.BigInteger;

public class A {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Solver solver = new Solver();
        solver.solve(1, in, out);

        out.close();
    }

    static class Solver {

        public static final double DD = 1.000000011;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long d = ((n / 10000) % 10) * 10000 + ((n / 100) % 10) * 1000 + (n % 10) * 100 + ((n / 10) % 10) * 10 + (n / 1000) % 10;
            BigInteger D = BigInteger.valueOf(d);
            D = D.pow(5);
            D = D.mod(BigInteger.valueOf(100000));
            String s = D.toString();
            while (s.length() < 5) s = "0" + s;
            out.println(s);
        }

    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

        public int[] nextIntArray(int size) {
            int[] result = new int[size];
            for (int i = 0; i < size; i++) {
                result[i] = nextInt();
            }
            return result;
        }

    }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger ;

/* Name of the class has to be "Main" only if the class is public. */
public  class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);

		String s = scan.nextLine();
		String a="" ;
		a = a + s.charAt(0);
		a = a +  s.charAt(2);
		a =  a+  s.charAt(4);
		a =  a + s.charAt(3);
		a = a +  s.charAt(1);

		BigInteger sum =  new BigInteger(a), ans ;
		ans=  sum.multiply(sum);
					ans =  ans.multiply(sum);
							ans =  ans.multiply(sum);
										ans =  ans.multiply(sum);
	//	System.out.println(ans);
		String as =  String.valueOf(ans);
		for( int i = as.length()-5 ; i <as.length(); i++)
		   		System.out.print(as.charAt(i));
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class L {

	private static BufferedReader br;
	private static StringTokenizer st;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		line();
		String n = nextToken();
		String a = "";
		a += n.charAt(0);
		a += n.charAt(2);
		a += n.charAt(4);
		a += n.charAt(3);
		a += n.charAt(1);
		BigInteger b = new BigInteger(a);
		String r = b.modPow(BigInteger.valueOf(5), BigInteger.valueOf(100000)).toString();
		while (r.length() < 5) {
			r = "0" + r;
		}
		System.out.println(r);

	}

	static void line() throws IOException {
		st = new StringTokenizer(br.readLine());
	}

	static long nextLong() {
		return Long.parseLong(nextToken());
	}

	static int nextInt() {
		return Integer.parseInt(nextToken());
	}

	static double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	static String nextToken() {
		return st.nextToken();
	}

}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int x = in.nextInt();
		int a = x / 10000;
		int b = x / 1000 % 10;
		int c = x / 100 % 10;
		int d = x / 10 % 10;
		int e = x % 10;
		long y = a * 10000 + c * 1000 + e * 100 + d * 10 + b;
		long res = y * y % 100000 * y % 100000 * y % 100000 * y % 100000;
		long a2 = res / 10000;
		long b2 = res / 1000 % 10;
		long c2 = res / 100 % 10;
		long d2 = res / 10 % 10;
		long e2 = res % 10;
		out.println("" + a2 + b2 + c2 + d2 + e2);

	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {

			solve(in, out);
		} /*
			 * catch (IOException e) { throw new Error(e); }
			 */

	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int a = in.nextInt();
		int c = (a / 10000) * 10000 + (a / 100) % 10 * 1000 + (a % 10) * 100 + (a / 10) % 10 * 10 + (a / 1000) % 10;
		long ans = c;
		for (int i = 0; i < 4; i++)
			ans = (ans * c) % 100000;
		if (ans < 10000)
			out.print(0);
		if (ans < 1000)
			out.print(0);
		if (ans < 100)
			out.print(0);
		if (ans < 10)
			out.print(0);
		out.print(ans);

	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)
		// Scanner in = new Scanner(new FileReader("input.txt"));
		// PrintWriter out = new PrintWriter(new FileWriter("output.txt"))
		) {

			solve(in, out);
		}
		/*
		 * catch (IOException e) { throw new Error(e); }
		 */
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class CrackingTheCode {

	public static void main(String[] args) {
		BigInteger x;
		Scanner s = new Scanner(System.in);
		String p = s.next();
		String res = "" + p.charAt(0) + p.charAt(2) + p.charAt(4) + p.charAt(3) + p.charAt(1);
		x = new BigInteger(res);
		x = x.pow(5);
		BigInteger y = new BigInteger("100000");
		x = x.mod(y);
		String ans = x.toString();
		int fin = Integer.parseInt(ans);
		System.out.printf("%05d", fin);

	}

}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int d1 = n / 10000 % 10;
		int d2 = n / 1000 % 10;
		int d3 = n / 100 % 10;
		int d4 = n / 10 % 10;
		int d5 = n / 1 % 10;
		long p = d1 * 10000 + d3 * 1000 + d5 * 100 + d4 * 10 + d2 * 1;
		final int mod = 100000;
		long r = p * p % mod * p % mod * p % mod * p % mod;
		long r1 = r / 10000 % 10;
		long r2 = r / 1000 % 10;
		long r3 = r / 100 % 10;
		long r4 = r / 10 % 10;
		long r5 = r / 1 % 10;
		out.print(r1);
		out.print(r2);
		out.print(r3);
		out.print(r4);
		out.print(r5);
	}

	void run() {
		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}

	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
import java.util.Scanner;

public class Main {
    void solve (Scanner sc, PrintWriter out) {
        int n = sc.nextInt();
        int x1=n/10000;
        n=n-x1*10000;
        int x2=n/1000;
        n=n-x2*1000;
        int x3=n/100;
        n=n-x3*100;
        int x4=n/10;
        int x5=n-x4*10;
        int t1=x2+x4*10+x5*100+x3*1000+x1*10000;
        long t3=1L*t1*t1*t1;
        long t4=1L*t1*t1;
        long res=((t3%100000)*(t4%100000))%100000;
       // out.println(res);
        long r1=res/10000;
        res=res-r1*10000;
        long r2=res/1000;
        res=res-r2*1000;
        long r3=res/100;
        res=res-r3*100;
        long r4=res/10;
        long r5=res-r4*10;
        out.print(r1);
        out.print(r2);
        out.print(r3);
        out.print(r4);
        out.print(r5);

        out.close();
    }
    void run(){
        try {
           // Scanner sc = new Scanner(new FileReader("sum.in"));
            Scanner sc = new Scanner(System.in);
            //PrintWriter out=new PrintWriter(new FileWriter("sum.out"));
            PrintWriter out=new PrintWriter(System.out);

            solve(sc, out);

        }
        catch (Exception e){
            throw new Error(e) ;
        }

    }
    public static void main(String[] args) {

        new Main().run();
    }
}

import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.Scanner;

public class A {

	static int[] prime = {2, 3, 5, 7};

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.nextLine();
		num = num.substring(0, 1) + num.substring(2, 3) + num.substring(4)+num.substring(3, 4) + num.substring(1,2);
		long seed = Long.parseLong(num);
		long answer = 1;
		for (int i =0; i<5; i++) {
			answer *= seed;
			answer %= 100000;
		}
		DecimalFormat df = new DecimalFormat("00000");
		System.out.println(df.format(answer));

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Template {

	public static void main(String[] args) throws IOException {

		Reader.init(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String x = Reader.next();

		StringBuilder sb = new StringBuilder();

		sb.append(x.charAt(0));
		sb.append(x.charAt(2));
		sb.append(x.charAt(4));
		sb.append(x.charAt(3));
		sb.append(x.charAt(1));

		BigInteger bg = new BigInteger(sb.toString());

		/*
		 * int y = Integer.parseInt(sb.toString()); long n = 1; long m = 1; n =
		 * (long) (Math.pow(y, 2)) % 100000; m = (long) (Math.pow(y, 3)) %
		 * 100000;
		 *
		 * long res = (long) (n * m) % 100000;
		 */
		out.println((bg.modPow(new BigInteger("5"), new BigInteger("100000"))) != BigInteger.ZERO
				? (bg.modPow(new BigInteger("5"), new BigInteger("100000"))) : "00000");
		out.flush();
	}

	static class Reader {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		/** call this method to initialize reader for InputStream */
		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		/** get next word */
		static String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {

				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}

	}

}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger ;

/* Name of the class has to be "Main" only if the class is public. */
public  class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);

		String s = scan.nextLine();
		String a="" ;
		a = a + s.charAt(0);
		a = a +  s.charAt(2);
		a =  a+  s.charAt(4);
		a =  a + s.charAt(3);
		a = a +  s.charAt(1);

		BigInteger sum =  new BigInteger(a), ans ;
		ans=  sum.multiply(sum);
		ans =  ans.multiply(sum);
		ans =  ans.multiply(sum);
		ans =  ans.multiply(sum);
	//	System.out.println(ans);
		String as =  String.valueOf(ans);
		for( int i = as.length()-5 ; i <as.length(); i++)
		   		System.out.print(as.charAt(i));
	}
}

import java.io.*;
import java.util.Scanner;

/**
 *
 * @author RIG
 */
public class AppPro {
    void solve(Scanner in,PrintWriter out){
    int n = in.nextInt();
    int i = n/10000;
    int ii = n/1000%10;
    int iii = n/100%10;
    int iv = n/10%10;
    int v = n%10;
    long p = i*10000 + iii *1000 + v*100 + iv*10 + ii;
    final int MOD = 100000;
    int r = (int) (p*p%MOD*p%MOD*p%MOD*p%MOD);
    int r_i = r/10000;
    int r_ii = r/1000%10;
    int r_iii = r/100%10;
    int r_iv = r/10%10;
    int r_v = r%10;
    out.println("" + r_i + r_ii + r_iii + r_iv + r_v);
    }
    void run(){
        try ( Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);)
            {
                solve(in,out);
            }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new AppPro().run();
    }
}

import java.io.*;
import static java.lang.Math.*;

import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;

public class Main {
    final static boolean debug = false;
    final static String fileName = "";
    final static boolean useFiles = false;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter writer = new PrintWriter(System.out);
        new Task(new InputReader(System.in), writer).solve();
        writer.close();
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public byte nextByte() {
        return Byte.parseByte(next());
    }
}

class Task {
    public void solve() {
        long n = in.nextInt();
        long result = (n / 10000) * 10000 + ((n / 100) % 10) * 1000 + (n % 10) * 100 + ((n / 10) % 10) * 10 + ((n / 1000) % 10);
        result = (result * result % 100000 * result * result % 100000 * result) % 100000;
        String s = ((Long)result).toString();
        out.println("00000".substring(0, 5 - s.length()) + s);
    }

    private InputReader in;
    private PrintWriter out;

    Task(InputReader in, PrintWriter out) {
        this.in = in;
        this.out = out;
    }
}

import java.io.*;
import java.util.StringTokenizer;

public class Main {

  private void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    int d1 = n / 10000;
    int d2 = n / 1000 % 10;
    int d3 = n / 100 % 10;
    int d4 = n / 10 % 10;
    int d5 = n % 10;
    long p = d1 * 10000 + d3 * 1000 + d5 * 100 + d4 * 10 + d2;
    final int MOD = 100000;
    int r = (int) (p * p % MOD * p % MOD * p % MOD * p % MOD);
    out.printf("%05d", r);
  }

  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try (
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }

  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {

    }
  }

}

import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Quan
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long a, b, c, d, e;
        a = n % 10;
        n /= 10;
        b = n % 10;
        n /= 10;
        c = n % 10;
        n /= 10;
        d = n % 10;
        n /= 10;
        e = n % 10;
        n /= 10;
        n = 10000 * e + 1000 * c + 100 * a + 10 * b + d;
        //System.out.println((int) Math.pow(n, 5) % 100000);
        long k = n;
        for (int i = 0; i < 4; i++) {
            k = (k * n) % 100000;
        }
        if (k != 0) {
            System.out.println(k);
        } else {
            System.out.println("00000");
        }
    }
}

//package codeforces.volbit;

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Created by umatayn on 11/1/16.
 */
public class ProblemL {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            @Override
            public void run() {
                ProblemL.run();
            }
        }, "solution", 1 << 23).start();
    }

    public static void run() {
        // initialize resources
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();

        final int d = 100000;
        int fifth = n % 10;
        n /= 10;
        int fourth = n % 10;
        n /= 10;
        int third = n % 10;
        n /= 10;
        int second = n % 10;
        n /= 10;
        int first = n;

        long m = first;
        m *= 10;
        m += third;
        m *= 10;
        m += fifth;
        m *= 10;
        m += fourth;
        m *= 10;
        m += second;

        out.print(String.format("%05d",((((m * m * m) % d) * ((m * m) %d)) % d)));

        // release resources
        out.close();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author P Marecki
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskL solver = new TaskL();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskL {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int num = in.nextInt();
            long[] a = new long[6];
            for (int i = 0; i < 5; i++) {
                a[5 - i] = num % 10;
                num /= 10;
            }
            long nnn = 10000 * a[1] + 1000 * a[3] + 100 * a[5] + 10 * a[4] + a[2];

            long m = 100000;
            long ans = nnn;
            for (int i = 0; i < 4; i++) {
                ans *= nnn;
                ans %= m;
            }
            for (int i = 0; i < 5; i++) {
                a[5 - i] = ans % 10;
                ans /= 10;
            }
            for (int i = 0; i < 5; i++) {
                out.print(a[1 + i]);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.*;
import java.util.*;
public class Main{
  void solve(Scanner in, PrintWriter out){
    int n = in.nextInt();
    int d1 = n / 10000;
    int d2 = n / 1000 % 10;
    int d3 = n / 100 % 10;
    int d4 = n / 10 % 10;
    int d5 = n % 10;
    long p = d1 * 10000 + d3 * 1000 + d5 * 100 +d4*10 + d2;
    final int MOD = 100000;
    int r =(int) (p*p%MOD*p%MOD*p%MOD*p%MOD);
    // (a * b) % p = ((a%p)*(b%p))%p и надо учесть, что м б ведущие 0
    int rd1 = r / 10000;
    int rd2 = r / 1000 % 10;
    int rd3 = r / 100 % 10;
    int rd4 = r / 10 % 10;
    int rd5 = r % 10;
    out.println(""+rd1+rd2+rd3+rd4+rd5);
  }
  void run(){
    try(
      Scanner in = new Scanner (System.in);
      PrintWriter out = new PrintWriter(System.out)){
        solve(in, out);
    }
  }
  public static void main(String args[]){
    new Main().run();
  }
}

import java.util.*;
import java.io.*;

/*
* 0000
* 0000
* 0000
* 0000
* */

public class Main {

    public void run(){
        try(
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out);
                )
        {
            solve(in,out);
        }
    }

    public void solve(Scanner sc, PrintWriter out){
        String str = sc.nextLine();
        StringBuilder sb = new StringBuilder();
        sb.append(str.charAt(0));
        sb.append(str.charAt(2));
        sb.append(str.charAt(4));
        sb.append(str.charAt(3));
        sb.append(str.charAt(1));
        long N = Long.parseLong(sb.toString());
        int p = 100000;
        System.out.printf("%05d",(((((N*N)%p*N)%p*N)%p*N)%p));
        }

    public static void main(String[] args) {
	// write your code here
        new Main().run();
    }
}

/* Author: Sagdat Kozhakhmetov
 * Date: 5 марта 2016 г.
 * Problem: Cracking code
 */

import java.io.*;
import java.util.*;

public class Main {
	void solve(Scanner in, PrintWriter out) {
		int N = in.nextInt();
		int N1 = N/10000;
		int N2 = N/1000%10;
		int N3 = N/100%10;
		int N4 = N/10%10;
		int N5 = N%10;

		long M = N1*10000 + N3*1000 + N5*100 + N4*10 + N2;

		long R = M*M%100000;
		R = R*M%100000;
		R = R*M%100000;
		R = R*M%100000;

		out.printf("%05d\n", R);
	}

	void run() {
		Locale.setDefault(Locale.US);

		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out);) {
			solve(in, out);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		long n = in.nextInt();
		long d1 = n / 10000;
		long d2 = n / 1000 % 10;
		long d3 = n / 100 % 10;
		long d4 = n / 10 % 10;
		long d5 = n % 10;

		n = (((d1 * 10 + d3) * 10 + d5) * 10 + d4) * 10 + d2;
		long d = n;
		for (int i = 0; i < 4; i++) {
			d = d * n % 100000;
		}

		if (d == 0) {
			out.println("00000");
		} else {
			out.println(d);
		}
	}

	void run() {
		try (
				Scanner in = new Scanner (System.in);
				PrintWriter out = new PrintWriter(System.out);
//				Scanner in = new Scanner(new FileReader("input.txt"));
//				PrintWriter out = new PrintWriter(new FileWriter("output.txt"));

		) {
			solve(in, out);
		}
//		catch (IOException e) {
//			throw new Error(e);
//		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int x = in.nextInt();
		int a = x / 10000;
		int b = x / 1000 % 10;
		int c = x / 100 % 10;
		int d = x / 10 % 10;
		int e = x % 10;
		long y = a * 10000 + c * 1000 + e * 100 + d * 10 + b;
		long res = y * y % 100000 * y % 100000 * y % 100000 * y % 100000;
		if (res == 0) {
			out.println("00000");
		} else {
			out.println(res);
		}

	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {

			solve(in, out);
		} /*
			 * catch (IOException e) { throw new Error(e); }
			 */

	}

	public static void main(String args[]) {
		new Main().run();
	}
}

//package com.company;
import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out){
        long n = in.nextLong();
        long k = n - (n % 10000) + (n % 1000)/100*1000 + n%10*100 + n%100/10*10 + n%10000/1000;
        int r = (int)(k * k % 100000 * k % 100000 * k % 100000 * k % 100000);
        int d1 = r/10000;
        int d2 = r%10000/1000;
        int d3 = r/100%10;
        int d4 = r%100/10;
        int d5 = r%10;
        out.println("" + d1 + d2 + d3 + d4 + d5);
    }
    //new FileReader("sum.in")
    //new FileWriter("sum.out")
    void run() {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out)
        ) {
            solve(in,out);
        } //catch(IOException e){
        //           throw new Error(e);
        //        }
    }

    public static void main(String[] args) {
	    new Main().run();
    }
}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int digit1 = n / 10000;
        int digit2 = n / 1000 % 10;
        int digit3 = n / 100 % 10;
        int digit4 = n % 100 / 10;
        int digit5 = n % 10;

        long num = digit1 * 10000 + digit3 * 1000 + digit5 * 100 + digit4 * 10 + digit2;

        long square = num*num;
        long cube = num*num*num;
        cube = cube % 100000;

        long res = cube * square;

        StringBuilder str = new StringBuilder();
        str.append(res);
        str.reverse();
        str.append("0000");
        str.reverse();
        String ress = str.substring(str.length()-5, str.length());
        out.print(ress);

    }

    void run() {
        try (Scanner in = new Scanner(System.in);
             PrintWriter out = new PrintWriter(System.out)) {

            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

//package codeforce;

import java.math.BigInteger;
import java.util.Scanner;

/* @author Kbk*/
public class CrackingTheCode {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String num=sc.next();
        String num2="";
        num2=num2+num.charAt(0)+num.charAt(2)+num.charAt(4)+num.charAt(3)+num.charAt(1);
        BigInteger b=new BigInteger(""+num2);
        b=b.pow(5);
        b=b.mod(b.valueOf(100000));
        String temp=""+b;
        if(temp.length()>=5)
            System.out.println(temp);
        else if(temp.length()<5){
            for(int i=5-temp.length();i>0;i--){
                temp='0'+temp;
            }
            System.out.println(temp);
        }
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.Random;
import java.util.StringTokenizer;

public class F {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        for(int tt = 1; tt <= t; tt++) solver.solve(tt, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            char[] s = scan.next().toCharArray();
            char[] res = {s[0], s[2], s[4], s[3], s[1]};
            long c = Long.parseLong(new String(res )), ans = 1, MOD = 100000;
            for(int i = 0; i < 5; i++) {
                ans *= c;
                ans %= MOD;
            }
            for(int i = 0; i < (5 - ("" + ans).length()); i++) out.print(0);
            out.println(ans);
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Template {

	public static void main(String[] args) throws IOException {

		Reader.init(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String x = Reader.next();

		StringBuilder sb = new StringBuilder();

		sb.append(x.charAt(0));
		sb.append(x.charAt(2));
		sb.append(x.charAt(4));
		sb.append(x.charAt(3));
		sb.append(x.charAt(1));

		BigInteger bg = new BigInteger(sb.toString());

		int y = Integer.parseInt(sb.toString());
		long n = 1;
		long m = 1;
		n = (long) (Math.pow(y, 2)) % 100000;
		m = (long) (Math.pow(y, 3)) % 100000;

		long res = (long) (n * m) % 100000;

		// out.println(bg.modPow(new BigInteger("5"), new
		// BigInteger("100000")));
		if (res != 0)
			out.println(res);
		else
			out.println("00000");
		out.flush();
	}

	static class Reader {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		/** call this method to initialize reader for InputStream */
		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		/** get next word */
		static String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {

				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}

	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class l {
public static void main(String[] args) throws IOException {
	input.init(System.in);
	PrintWriter out = new PrintWriter(System.out);
	String s = input.next();
	s = s.charAt(0) + "" + s.charAt(2)+""+s.charAt(4)+""+s.charAt(3)+""+s.charAt(1);
	BigInteger bi = new BigInteger(s);
	bi = bi.pow(5).mod(BigInteger.valueOf(100000));
	String res = bi.toString();
	while(res.length() < 5) res = "0"+res;
	out.println(res);
	out.close();
}

public static class input {
	static BufferedReader reader;
	static StringTokenizer tokenizer;

	static void init(InputStream input) {
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
	}

	static String next() throws IOException {
		while (!tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(reader.readLine());
		return tokenizer.nextToken();
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}
}

import java.util.*;
import java.io.*;
public class CodeCracking
{

	/************************ SOLUTION STARTS HERE ************************/

	//DONT FORGET TO COMMIT AND PUSH TO GITHUB
	static long mod = (long)1e5;
	private static long modPow(long a,long b)   /* Modular exponentiation  */
	{
		if(b == 0L || a == 1L)
			return 1L;
		else if(b == 1L)
			return a;
		else
		{
			if((b & 1L) == 0L)  		//Checking whether b is even (fast)
				return modPow((a * a) % mod,b / 2L);
			else
				return (a * modPow((a * a) % mod,((b - 1L) / 2L))) % mod ;
		}
	}
	private static void solve(FastScanner s1, FastWriter out){

		char in[] = s1.nextLine().toCharArray();
		char num[] = new char[5];
		num[0] = in[0];
		num[1] = in[2];
		num[2] = in[4];
		num[3] = in[3];
		num[4] = in[1];
		long n = Long.parseLong(new String(num));
		long ans = modPow(n, 5L)%mod ;
		String correct = String.valueOf(ans);
		if(correct.length() != 5)
		{
			for(int i=1,len = correct.length();i<=5-len;i++)
				correct = "0"+correct;

			out.print(correct);
			return;
		}
		out.print(ans);
	}
//36551
	/************************ SOLUTION ENDS HERE ************************/

	/************************ TEMPLATE STARTS HERE ************************/

	public static void main(String []args) throws IOException {
		FastScanner in  = new FastScanner(System.in);
		FastWriter  out = new FastWriter(System.out);
		solve(in, out);
		in.close();
		out.close();
	}

	static class FastScanner{
		public BufferedReader reader;
		public StringTokenizer st;
		public FastScanner(InputStream stream){
			reader = new BufferedReader(new InputStreamReader(stream));
			st = null;
		}
		public String next(){
			while(st == null || !st.hasMoreTokens()){
				try{
					String line = reader.readLine();
					if(line == null) return null;
					st = new StringTokenizer(line);
				}catch (Exception e){
					throw (new RuntimeException());
				}
			}
			return st.nextToken();
		}
		public String nextLine(){
			String str = null;
			try {
				str = reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}
		public void close(){
			try{ reader.close(); } catch(IOException e){e.printStackTrace();}
		}
	}
	static class FastWriter{
		BufferedWriter writer;
		public FastWriter(OutputStream stream){
			writer = new BufferedWriter(new OutputStreamWriter(stream));
		}
		public void print(int i) {
			print(Integer.toString(i));
		}
		public void println(int i) {
			print(Integer.toString(i));
			print('\n');
		}
		public void print(long i) {
			print(Long.toString(i));
		}
		public void println(long i) {
			print(Long.toString(i));
			print('\n');
		}
		public void print(double i) {
			print(Double.toString(i));
		}
		public void print(boolean i) {
			print(Boolean.toString(i));
		}
		public void print(Object o){
			print(o.toString());
		}
		public void println(Object o){
			print(o.toString());
			print('\n');
		}
		public void print(char i) {
			try{writer.write(i);} catch(IOException e){e.printStackTrace();}
		}
		public void print(String s){
			try{writer.write(s);} catch(IOException e){e.printStackTrace();}
		}
		public void println(String s){
			try{writer.write(s);writer.write('\n');} catch(IOException e){e.printStackTrace();}
		}
		public void println(){
			try{writer.write('\n');} catch(IOException e){e.printStackTrace();}
		}
		public void print(int arr[])
		{
			for (int i = 0; i < arr.length; i++) {
				print(arr[i]);
				print(' ');
			}
		}
		public void close(){
			try{writer.close();} catch(IOException e){e.printStackTrace();}
		}
	}

	/************************ TEMPLATE ENDS HERE ************************/
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int x = in.nextInt();
		int a = x / 10000;
		int b = x / 1000 % 10;
		int c = x / 100 % 10;
		int d = x / 10 % 10;
		int e = x % 10;
		long y = a * 10000 + c * 1000 + e * 100 + d * 10 + b;
		long res = y * y % 100000 * y % 100000 * y % 100000 * y % 100000;
		out.println(res);

	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {

			solve(in, out);
		} /*
			 * catch (IOException e) { throw new Error(e); }
			 */

	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
import java.util.*;

public class Main {
	void solve(Scanner in, PrintWriter out) {
        int number = in.nextInt();
        int rest = 100_000;

        int fifth = number % 10;
        number /= 10;
        int fourth = number % 10;
        number /= 10;
        int third = number % 10;
        number /= 10;
        int second = number % 10;
        number /= 10;
        int first = number % 10;
        number /= 10;

        number = first * 10_000 + third * 1000 + fifth * 100 + fourth * 10 + second;
        long numberOnFive;
        numberOnFive = ((long)number * number) % rest; // 2
        numberOnFive = (numberOnFive * number) % rest; // 3
        numberOnFive = (numberOnFive * number) % rest; // 4
        numberOnFive = (numberOnFive * number) % rest; // 5

        out.println(numberOnFive);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);
		) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Solution{

    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();

            int d1 = n / 10000;
            int d2 = n / 1000 % 10;
            int d3 = n / 100 % 10;
            int d4 = n / 10 % 10;
            int d5 = n % 10;

            int p = d1 * 10000 + d3 * 1000 + d5 * 100 + d4 * 10 + d2;
            BigInteger p1 = new BigInteger(p + "");
            p1 = p1.pow(5);
            out.println(p1);
            String answer = p1.toString();
            answer = answer.substring(answer.length()-5,answer.length());
            n = Integer.parseInt(answer);
        if(n == 0)
            out.println(answer);
        else
            out.println(n);

        out.close();
        sc.close();

    }

}

import java.io.*;
import java.util.*;

public class Main {
    void solve(StreamTokenizer in,PrintWriter out) throws IOException  {
        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));

        String n=r.readLine();
        String a="";
        a+=n.charAt(0);
        a+=n.charAt(2);
        a+=n.charAt(4);
        a+=n.charAt(3);
        a+=n.charAt(1);
        long b=Long.parseLong(a);
        long p=((((b*b%100000)*b)%100000*b)%100000*b)%100000;
        out.print(p);

    }
    StreamTokenizer in;
    PrintWriter out;

    int nextInt() throws IOException
    {
        in.nextToken();
        return (int)in.nval;
    }
    long nextLong() throws IOException
    {
        in.nextToken();
        return  (long)in.nval;
    }

    void run() throws IOException  {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out =new PrintWriter(System.out);
        solve(in,out);
        out.flush();
    }

    public static void main(String[] args)throws IOException  {
        // write your code here
        new Main().run();

    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;

public class main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] p = {0, 4, 1, 3, 2};

    public static void main(String[] args) throws Exception{
        String s = br.readLine();

        char[] a = new char[5];
        for(int i = 0; i < 5; i++){
            a[p[i]] = s.charAt(i);
        }
        int N = 0;
        // pw.print(Arrays.toString(a));
        for(int i = 0; i < 5; i++){
            N += (a[i]-'0') * Math.pow(10, 5-i-1);
            // pw.print(N + "\n");
        }
        // pw.print(N + "\n");
        long total = 1;
        for(int i = 0; i < 5; i++){
            total = (total * N) % 100000;
        }
        pw.print(total + "\n");
        pw.close();
        br.close();
    }
}

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int c1 = n / 10000;
		int c2 = n / 1000 % 10;
		int c3 = n / 100 % 10;
		int c4 = n % 100 / 10;
		int c5 = n % 10;
		long k = c1 * 10000 + c3 * 1000 + c5 * 100 + c4 * 10 + c2;
		final int m = 100000;
		int s = (int)(k * k % m * k % m * k % m * k % m);
		out.println(s);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {

			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int a = in.nextInt();
		int dt = a / 10000;
		int t = (a / 1000) % 10;
		int s = (a / 100) % 10;
		int d = (a % 100) / 10;
		int e = a % 10;
		long anew = dt * 10000 + s * 1000 + e * 100 + d * 10 + t;
		long shet1 = (anew % 100000 * anew % 100000 * anew % 100000 * anew % 100000 * anew % 100000) % 100000;
		out.println(shet1);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {

        long n = in.nextLong();
        long n1 = (n - n % 10000);
        long n2 = (n % 1000 - n % 100) * 10;
        long n3 = (n%10)*100;
        long n4 = n%100 - n%10;
        long n5 = (n / 1000) % 10;
        long number = (n2 + n3 + n4 + n5);

        System.out.println((number*number*number*number*number)%100000);

    }

    void run() {
        try ( Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    int z = in.nextInt();
    int a = z/10000;
    int b = z/1000 - a*10;
    int c = z/100 - a*100 - b*10;
    int d = (z%100)/10;
    int e = z%10;
    int z2 = a*10000 + c*1000 + e*100 + d*10 + b;
    int x = (((((((z2*z2)%100000)*z2)%100000)*z2)%100000)*z2)%100000;
    System.out.println(x);
  }
}

import java.io.*;
import static java.lang.Math.*;

import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;

public class Main {
    final static boolean debug = false;
    final static String fileName = "";
    final static boolean useFiles = false;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter writer = new PrintWriter(System.out);
        new Task(new InputReader(System.in), writer).solve();
        writer.close();
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public byte nextByte() {
        return Byte.parseByte(next());
    }
}

class Task {
    public void solve() {
        long n = in.nextInt();
        long result = (n / 10000) * 10000 + ((n / 100) % 10) * 1000 + (n % 10) * 100 + ((n / 10) % 10) * 10 + ((n / 1000) % 10);
        result = (result * result % 100000 * result * result % 100000 * result) % 100000;
        out.println(result);
    }

    private InputReader in;
    private PrintWriter out;

    Task(InputReader in, PrintWriter out) {
        this.in = in;
        this.out = out;
    }
}

import java.io.*;
import java.util.Scanner;

public class Main {

    void solve(Scanner in, PrintWriter out){
       int n = in.nextInt();
       int res = 0;
       res = n/10000 * 10000;
       res += (n%1000)/100 * 1000;
       res += n%10 * 100;
       res += (n%100)/10 * 10;
       res += (n%10000)/1000;
       long g = res;
       for(int i=0;i<4;i++){
           g = (g*res)%100000;
       }
        out.println(g);

    }
    void run(){
        try(PrintWriter out = new PrintWriter(System.out))
        {
            Scanner in = new Scanner(System.in);

            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

import java.util.Scanner;

public class Zadacha {

	public static void main(String[] args) throws java.io.IOException{
		Scanner scan = new Scanner(System.in);
		int code = scan.nextInt();
		int d5 = code%10;
		int	d4 = code%100/10;
		int	d3 = code%1000/100;
		int	d2 = code%10000/1000;
		int	d1 = code/10000;

		int transformed_code = d1*10000 + d3*1000 + d5*100 + d4*10 + d2;
		long result = transformed_code*transformed_code%100000;

		for(int i = 0; i<3; i++) {
			result = result * transformed_code%100000;
		}

		d1 = (int)result/10000;
		d2 = (int)result%10000/1000;
		d3 = (int)result%1000/100;
		d4 = (int)result%100/10;
		d5 = (int)result%10;

		System.out.println(d1 +""+ d2 +""+ d3 +""+ d4 +""+ d5);
	}

}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {

		int n = in.nextInt();

		long n1 = ((n / 10000) * 10000 + (n / 100 % 10) * 1000 + (n % 10) * 100 + (n / 10 % 10) * 10 + (n / 1000 % 10));

		out.println((n1 * n1 * n1 % 100000) * (n1 * n1 % 100000) % 100000);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.*;
import java.util.*;

public class Main {

	private void solve(Scanner in, PrintWriter out) {
		long n = in.nextLong();
		n = n / 10000 % 10 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 + n / 10 % 10 * 10 + n / 1000 % 10;
		long r = n;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		out.println(r);
	}

	private void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    String s  = in.next();
 int a = s.charAt(0)-48;
 int b = s.charAt(1)-48;
 int c = s.charAt(2)-48;
 int d = s.charAt(3)-48;
 int e = s.charAt(4)-48;
 int k =a*10000+c*1000+e*100+d*10+b;

  BigInteger n = BigInteger.valueOf(k);
  n=n.pow(5);
   BigInteger m = BigInteger.valueOf(10000);
  n=n.mod(m);
  out.print(n);
   out.flush();
}
}

/* Author: Sagdat Kozhakhmetov
 * Date: 5 марта 2016 г.
 * Problem: Cracking code
 */

import java.io.*;
import java.util.*;

public class Main {
	void solve(Scanner in, PrintWriter out) {
		int N = in.nextInt();
		int N1 = N/10000;
		int N2 = N/1000%10;
		int N3 = N/100%10;
		int N4 = N/10%10;
		int N5 = N%10;

		long M = N1*10000 + N3*1000 + N5*100 + N4*10 + N2;

		long R = M*M%100000;
		R = R*M%100000;
		R = R*M%100000;
		R = R*M%100000;

		out.println(R%100000);
	}

	void run() {
		Locale.setDefault(Locale.US);

		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out);) {
			solve(in, out);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int d1 = n / 10000 % 10;
		int d2 = n / 1000 % 10;
		int d3 = n / 100 % 10;
		int d4 = n / 10 % 10;
		int d5 = n / 1 % 10;
		long p = d1 * 10000 + d3 * 1000 + d5 * 100 + d4 * 10 + d2 * 1;
		final int mod = 100000;
		long r = p * p % mod * p % mod * p % mod * p % mod;
		out.println(r);
		long r1 = r / 10000 % 10;
		long r2 = r / 1000 % 10;
		long r3 = r / 100 % 10;
		long r4 = r / 10 % 10;
		long r5 = r / 1 % 10;
		out.println("" + r1 + r2 + r3 + r4 + r5);
	}

	void run() {
		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}

	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

public class Main
{
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt();
    int m = n / 10000;
    m = m * 10 + (n / 100) % 10;
    m = m * 10 + n % 10;
    m = m * 10 + (n / 10) % 10;
    m = m * 10 + (n / 1000) % 10;
	System.out.println(m);
    BigInteger f = BigInteger.ONE;
    for (int i = 1; i <= 5; i++) {
      f = f.multiply(BigInteger.valueOf(m));
    }
    BigInteger WHAT = BigInteger.valueOf(100000);
    f = f.mod(WHAT);
    System.out.println(f.toString());
    out.close();
  }
}

import java.util.Scanner;
import java.io.PrintWriter;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int firstDigit = n / 10_000;
		int secondDigit = n / 1_000 % 10;
		int thirdDigit = n / 100 % 10;
		int fourthDigit = n / 10 % 10;
		int fifthDigit = n % 10;

		long reverseN = firstDigit * 10_000 + thirdDigit * 1_000 + fifthDigit * 100 + fourthDigit * 10 + secondDigit;
		long reverseNewN = reverseN;
		reverseNewN = reverseNewN * reverseN;
		reverseNewN = (reverseNewN % 100_000L) * (reverseN % 100_000L) % 100_000L;
		reverseNewN = (reverseNewN % 100_000L) * (reverseN % 100_000L) % 100_000L;
		reverseNewN = (reverseNewN % 100_000L) * (reverseN % 100_000L) % 100_000L;

		out.print(reverseNewN);
	}

	void run() {
		try(
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

import java.util.*;
import java.lang.*;
public class p630n{
	public static void main(String []args){
		Scanner s=new Scanner(System.in);
		int  i=s.nextInt();
		int a5=(i%10)*100,a4=((i/10)%10)*10,a3=((i/100)%10)*1000,a2=((i/1000)%10),a1=((i/10000)%10)*10000;
		a1+=a2+a3+a4+a5;
		int x=a1,h=4;
		while(h-->0){
			a1*=x;
			a1%=100000;
		}
		System.out.println(a1);

	}
}

import java.io.*;
import java.util.InputMismatchException;

public class EERK {
    private static InputReader in = new InputReader(System.in);
    private static OutputWriter out = new OutputWriter(System.out);

    private static void solve() throws Exception {
        String s = in.readString();
        StringBuilder nS = new StringBuilder();
        nS.append(s.charAt(0));
        nS.append(s.charAt(2));
        nS.append(s.charAt(4));
        nS.append(s.charAt(3));
        nS.append(s.charAt(1));
        long n = Long.parseLong(nS.toString());
        long result = (((n*n)%100000)*n)%100000;
        result = (((result*n)%100000)*n)%100000;
        out.println(result);
    }

    public static void main(String[] args) throws Exception {
        solve();
        out.close();
    }

    private static class InputReader {
        private InputStream stream;
        private byte[] buffer;
        private int currentIndex;
        private int bytesRead;

        public InputReader(InputStream stream) {
            this.stream = stream;
            buffer = new byte[131072];
        }

        public InputReader(InputStream stream, int bufferSize) {
            this.stream = stream;
            buffer = new byte[bufferSize];
        }

        private int read() throws IOException {
            if (currentIndex >= bytesRead) {
                currentIndex = 0;
                bytesRead = stream.read(buffer);
                if (bytesRead <= 0) {
                    return -1;
                }
            }
            return buffer[currentIndex++];
        }

        public String readString() throws IOException {
            int c = read();
            while (!isPrintable(c)) {
                c = read();
            }
            StringBuilder result = new StringBuilder();
            do {
                result.appendCodePoint(c);
                c = read();
            } while (isPrintable(c));
            return result.toString();
        }

        public int readInt() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            int result = 0;
            do {
                if ((c < '0') || (c > '9')) {
                    throw new InputMismatchException();
                }
                result *= 10;
                result += (c - '0');
                c = read();
            } while (isPrintable(c));
            return sign * result;
        }

        public long readLong() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            long result = 0;
            do {
                if ((c < '0') || (c > '9')) {
                    throw new InputMismatchException();
                }
                result *= 10;
                result += (c - '0');
                c = read();
            } while (isPrintable(c));
            return sign * result;
        }

        public double readDouble() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            boolean fraction = false;
            double multiplier = 1;
            double result = 0;
            do {
                if ((c == 'e') || (c == 'E')) {
                    return sign * result * Math.pow(10, readInt());
                }
                if ((c < '0') || (c > '9')) {
                    if ((c == '.') && (!fraction)) {
                        fraction = true;
                        c = read();
                        continue;
                    }
                    throw new InputMismatchException();
                }
                if (fraction) {
                    multiplier /= 10;
                    result += (c - '0') * multiplier;
                    c = read();
                } else {
                    result *= 10;
                    result += (c - '0');
                    c = read();
                }
            } while (isPrintable(c));
            return sign * result;
        }

        private boolean isPrintable(int c) {
            return ((c > 32) && (c < 127));
        }
    }

    private static class OutputWriter {
        private PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }
    }
}

import java.util.*;
public class ProL {
	static int n;
	static String a,b;
	static char[] aa;
	static long ans;

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		n=in.nextInt();
		a=Integer.toString(n);
		aa=a.toCharArray();
		b="";
		b+=aa[0]+""+aa[2]+""+aa[4]+""+aa[3]+""+aa[1];
		n=Integer.parseInt(b);
		ans=1;
		for(int i=0;i<5;i++)
			ans=(ans*n)%100000;
		System.out.println(ans);
	}
}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

public class Main
{
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt();
    int m = n / 10000;
    m = m * 10 + (n / 100) % 10;
    m = m * 10 + n % 10;
    m = m * 10 + (n / 10) % 10;
    m = m * 10 + (n / 1000) % 10;
	//System.out.println(m);
    BigInteger f = BigInteger.ONE;
    for (int i = 1; i <= 5; i++) {
      f = f.multiply(BigInteger.valueOf(m));
    }
    BigInteger WHAT = BigInteger.valueOf(100000);
    f = f.mod(WHAT);
    System.out.println(f.toString());
    out.close();
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Template {

	public static void main(String[] args) throws IOException {

		Reader.init(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String x = Reader.next();

		StringBuilder sb = new StringBuilder();

		sb.append(x.charAt(0));
		sb.append(x.charAt(2));
		sb.append(x.charAt(4));
		sb.append(x.charAt(3));
		sb.append(x.charAt(1));

		BigInteger bg = new BigInteger(sb.toString());
		/*int y = Integer.parseInt(sb.toString());
		long n = 1;
		long m = 1;
		n = (long) (Math.pow(y, 2)) % 100000;
		m = (long) (Math.pow(y, 3)) % 100000;

		long res = (long) (n * m) % 100000;
*/
		out.println(bg.modPow(new BigInteger("5"), new BigInteger("100000")));

		out.flush();
	}

	static class Reader {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		/** call this method to initialize reader for InputStream */
		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		/** get next word */
		static String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {

				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}

	}

}

import java.io.*;
import java.util.InputMismatchException;

public class EERK {
    private static InputReader in = new InputReader(System.in);
    private static OutputWriter out = new OutputWriter(System.out);

    private static void solve() throws Exception {
        String s = in.readString();
        StringBuilder nS = new StringBuilder();
        nS.append(s.charAt(0));
        nS.append(s.charAt(2));
        nS.append(s.charAt(4));
        nS.append(s.charAt(3));
        nS.append(s.charAt(1));
        long n = Long.parseLong(nS.toString());
        long result = (((n*n*n)%100000)*n*n)%100000;

        out.println(result);
    }

    public static void main(String[] args) throws Exception {
        solve();
        out.close();
    }

    private static class InputReader {
        private InputStream stream;
        private byte[] buffer;
        private int currentIndex;
        private int bytesRead;

        public InputReader(InputStream stream) {
            this.stream = stream;
            buffer = new byte[131072];
        }

        public InputReader(InputStream stream, int bufferSize) {
            this.stream = stream;
            buffer = new byte[bufferSize];
        }

        private int read() throws IOException {
            if (currentIndex >= bytesRead) {
                currentIndex = 0;
                bytesRead = stream.read(buffer);
                if (bytesRead <= 0) {
                    return -1;
                }
            }
            return buffer[currentIndex++];
        }

        public String readString() throws IOException {
            int c = read();
            while (!isPrintable(c)) {
                c = read();
            }
            StringBuilder result = new StringBuilder();
            do {
                result.appendCodePoint(c);
                c = read();
            } while (isPrintable(c));
            return result.toString();
        }

        public int readInt() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            int result = 0;
            do {
                if ((c < '0') || (c > '9')) {
                    throw new InputMismatchException();
                }
                result *= 10;
                result += (c - '0');
                c = read();
            } while (isPrintable(c));
            return sign * result;
        }

        public long readLong() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            long result = 0;
            do {
                if ((c < '0') || (c > '9')) {
                    throw new InputMismatchException();
                }
                result *= 10;
                result += (c - '0');
                c = read();
            } while (isPrintable(c));
            return sign * result;
        }

        public double readDouble() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            boolean fraction = false;
            double multiplier = 1;
            double result = 0;
            do {
                if ((c == 'e') || (c == 'E')) {
                    return sign * result * Math.pow(10, readInt());
                }
                if ((c < '0') || (c > '9')) {
                    if ((c == '.') && (!fraction)) {
                        fraction = true;
                        c = read();
                        continue;
                    }
                    throw new InputMismatchException();
                }
                if (fraction) {
                    multiplier /= 10;
                    result += (c - '0') * multiplier;
                    c = read();
                } else {
                    result *= 10;
                    result += (c - '0');
                    c = read();
                }
            } while (isPrintable(c));
            return sign * result;
        }

        private boolean isPrintable(int c) {
            return ((c > 32) && (c < 127));
        }
    }

    private static class OutputWriter {
        private PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }
    }
}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {

        long n = in.nextLong();
        long n1 = (n - n % 10000);
        long n2 = (n % 1000 - n % 100) * 10;
        long n3 = (n%10)*100;
        long n4 = n%100 - n%10;
        long n5 = (n / 1000) % 10;
        long number = (n2 + n3 + n4 + n5);

        System.out.println((number*number*number*number*number)%100000);

    }

    void run() {
        try ( Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int a = in.nextInt();
		int dt = a / 10000;
		int t = (a / 1000) % 10;
		int s = (a / 100) % 10;
		int d = (a % 100) / 10;
		int e = a % 10;
		long anew = dt * 10000 + s * 1000 + e * 100 + d * 10 + t;
		long shet1 = (anew % 100000 * anew % 100000 * anew % 100000 * anew % 100000 * anew % 100000) % 100000;
		out.println(shet1);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.io.PrintWriter;
import java.io.OutputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Alex
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskL solver = new TaskL();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskL {
        int g(char c) {
            return c - '0';
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
//        int n = in.readInt();
            char[] a = in.next().toCharArray();
            int shuff = g(a[0]) * 10000 +
                    g(a[2]) * 1000 +
                    g(a[4]) * 100 +
                    g(a[3]) * 10 +
                    g(a[1]);
            BigInteger pow = BigInteger.valueOf(shuff).modPow(BigInteger.valueOf(5), BigInteger.valueOf(100000));
//        out.printLine(IntegerUtils.power(shuff, 5, 100000));
            out.printLine(pow);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if(numChars == -1)
                throw new InputMismatchException();
            if(curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch(IOException e) {
                    throw new InputMismatchException();
                }
                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while(isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                if(Character.isValidCodePoint(c))
                    res.appendCodePoint(c);
                c = read();
            } while(!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if(filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for(int i = 0; i < objects.length; i++) {
                if(i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class L_Volbit {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int[]per = {0,2,4,3,1};
        char[] line = in.next().toCharArray();
        char[]cur = new char[5];
        for(int i = 0; i < 5; i++){
            cur[i] = line[per[i]];
        }
        long v = Long.parseLong(new String(cur));
        long result = pow(v, 5, 100000);
        out.println(result);
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.*;
import static java.lang.Math.*;

import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;

public class Main {
    final static boolean debug = false;
    final static String fileName = "";
    final static boolean useFiles = false;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter writer = new PrintWriter(System.out);
        new Task(new InputReader(System.in), writer).solve();
        writer.close();
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public byte nextByte() {
        return Byte.parseByte(next());
    }
}

class Task {
    public void solve() {
        long n = in.nextInt();
        long result = (n / 10000) * 10000 + ((n / 100) % 10) * 1000 + (n % 10) * 100 + ((n / 10) % 10) * 10 + ((n / 1000) % 10);
        result = (result * result % 100000 * result * result * result) % 100000;
        out.println(result);
    }

    private InputReader in;
    private PrintWriter out;

    Task(InputReader in, PrintWriter out) {
        this.in = in;
        this.out = out;
    }
}

import java.io.*;
import java.util.Scanner;

/**
 *
 * @author RIG
 */
public class AppPro {
    void solve(Scanner in,PrintWriter out){
        long a = in.nextInt();
        long i = a/10000;
        long ii = a/1000%10;
        long iii = a/100%10;
        long iv = a/10%10;
        long v = a%10;
        long p = i*10000+ iii *1000 + v*100+iv*10+ii;
        long res = Math.abs(((((p*p)%100000*p)%100000*p)%100000*p)%100000);
        out.println(res);

    }
    void run(){
        try ( Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);)
            {
                solve(in,out);
            }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new AppPro().run();
    }
}

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class L {

	public static void main(String[] args) {

		try (final Scanner sc = new Scanner(System.in)) {
			final String input = sc.next();

			StringBuilder sb = new StringBuilder();
			sb.append(input.charAt(0));
			sb.append(input.charAt(2));
			sb.append(input.charAt(4));
			sb.append(input.charAt(3));
			sb.append(input.charAt(1));

			System.out.println(new BigInteger(sb.toString()).pow(5).mod(BigInteger.valueOf(100000)));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {
					tok = new StringTokenizer(br.readLine());
				}
			} catch (IOException e) { /* ignore */
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public void close() {
			try {
				br.close();
			} catch (IOException e) { /* ignore */
			}
		}
	}
}

import java.util.Scanner;

public class Zadacha {

	public static void main(String[] args) throws java.io.IOException{
		Scanner scan = new Scanner(System.in);
		int code = scan.nextInt();
		int d5 = code%10;
		int	d4 = code%100/10;
		int	d3 = code%1000/100;
		int	d2 = code%10000/1000;
		int	d1 = code/10000;

		int transformed_code = d1*10000 + d3*1000 + d5*100 + d4*10 + d2;
		int result = transformed_code*transformed_code%100000;

		for(int i = 0; i<3; i++) {
			result = result * transformed_code%100000;
		}

		d1 = result/10000;
		d2 = result%10000/1000;
		d3 = result%1000/100;
		d4 = result%100/10;
		d5 = result%10;

		System.out.println(d1 +""+ d2 +""+ d3 +""+ d4 +""+ d5);
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main2 {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		n = (n/10000%10) * 10000 + (n/100%10) * 1000 + (n%10) * 100 + (n/10%10) * 10 + n/1000%10;
		long ans = n;
		for(int i = 1; i < 5; ++i)
			ans = (ans * n)%100000;
		out.println(ans);
		out.flush();
		out.close();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}

	}
}

import java.util.Scanner;

/**
 * Created by brunoob on 06.03.16.
 */
public class CrackingCode {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] digits = new int[5];
		for (int i = 4; i>= 0; i--) {
			digits[i] = n % 10;
			n = n / 10;
		}
		int a = digits[1] + 10 * digits[3] + 100 * digits[4] + 1000 * digits[2] + 10000 * digits[0];

		long sol = a;
		for(int i=0; i<4; i++){
			sol=(sol*a)%100000;
		}
		System.out.print(sol);
	}
}

import java.io.*;
import java.util.Scanner;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		long n = in.nextLong();
		n = n / 10000 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 + (n / 10) % 10 * 10 + (n / 1000) % 10;
		out.println(n);
		int i = 100000;
		long s;
		s = n * n * n * n;
		out.println(((s % i) * (n % i)) % i);

	}

	void run() {
		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}

}

import java.io.*;
import java.util.Scanner;

/**
 *
 * @author RIG
 */
public class AppPro {
    void solve(Scanner in,PrintWriter out){
        int a = in.nextInt();
        int i = a/10000;
        int ii = a/1000%10;
        int iii = a/100%10;
        int iv = a/10%10;
        int v = a%10;
        int p = i*10000+ iii *1000 + v*100+iv*10+ii;
        int res = Math.abs(((((p*p)%100000*p)%100000*p)%100000*p)%100000);
        int res_i = res/10000;
        int res_ii = res/1000%10;
        int res_iii = res/100%10;
        int res_iv = res/10%10;
        int res_v = res%10;
        out.println(res_i*10000+ res_ii *1000 + res_iii*100+res_iv*10+res_v);

    }
    void run(){
        try ( Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);)
            {
                solve(in,out);
            }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new AppPro().run();
    }
}

import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		n = n / 10000 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 + n / 10 % 10 * 10 + n / 1000 % 10;
		n = (long) (((((long)(Math.pow(n, 2)) % 100000)*((long)(Math.pow(n, 2)) % 100000))*n)%100000);
		System.out.print(n);
	}

}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {

		int n = in.nextInt();

		long n1 = ((n / 10000) * 10000 + (n / 100 % 10) * 1000 + (n % 10) * 100 + (n / 10 % 10) * 10 + (n / 1000 % 10));

		out.println((n1 * n1 * n1 % 100000) * (n1 * n1 % 100000) % 100000);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.util.*;
import java.lang.*;
public class p630n{
	public static void main(String []args){
		Scanner s=new Scanner(System.in);
		int  i=s.nextInt();
		int a5=(i%10)*100,a4=((i/10)%10)*10,a3=((i/100)%10)*1000,a2=((i/1000)%10),a1=((i/10000)%10)*10000;
		a1+=a2+a3+a4+a5;
		long x=a1;
		int h=4;
		while(h-->0){
			x*=a1;
			x%=100000;
		}
		System.out.println(x);

	}
}

import java.util.Scanner;

/**
 * Created by brunoob on 06.03.16.
 */
public class CrackingCode {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] digits = new int[5];
		for (int i = 4; i>= 0; i--) {
			digits[i] = n % 10;
			n = n / 10;
		}
		int a = digits[1] + 10 * digits[3] + 100 * digits[4] + 1000 * digits[2] + 10000 * digits[0];

		int sol = a;
		for(int i=0; i<4; i++){
			sol=(sol*a)%100000;
		}
		System.out.print(sol);
	}
}

import java.io.*;
import java.util.*;

public class Main {
	void solve(Scanner in, PrintWriter out) {
		long n = in.nextLong();
		long mix = (n / 10000) * 10000 + (n / 100 % 10) * 1000 + (n % 10) * 100 + (n / 10 % 10) * 10 + (n / 1000 % 10);
		out.println((mix * mix % 100000) * (mix * mix * mix % 100000) % 100000);
	}

	void run() {
		try ( Scanner in = new Scanner(System.in);
			  PrintWriter out = new PrintWriter(System.out) ) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class JavaApplication1 {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String n=scanner.next();

        String number=""+n.charAt(0)+n.charAt(2)+n.charAt(4)+n.charAt(3)+n.charAt(1);
        System.out.println(number);

        BigInteger b=new BigInteger(number);
        b=b.pow(5);
        System.out.println(b);
        number=b.toString();
        System.out.println(number.substring((number.length()-1)-4));
    }
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int d1 = n / 10000,
			d2 = n / 1000 % 10,
			d3 = n / 100 % 10,
			d4 = n / 10 % 10,
			d5 = n % 10;
		long p = d1 * 10000 + d3 * 1000 + d5 * 100 + d4 * 10 + d2;
		out.println(p);
		final int q = 100000;
		// (a * b) % q = ((a % q) * (b % q)) % q
		// (p^5) % q = ((p^3 % q) * (p^2 % q)) % q = ((((p*p % q) * (p % q)) % q) * (((p % q) * (p % q)) % q)) % q
		out.print(((((p*p % q) * (p % q)) % q) * (((p % q) * (p % q)) % q)) % q);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}
	}

	public static void main(String args[])
	{
		new Main().run();
	}
}

import java.util.Scanner;
import java.math.BigInteger;
public class Codeforce {
   public static void main ( String[] args ) {
      Scanner input = new Scanner( System.in);

      int n = input.nextInt();
      int bir = code(n);

      String temp = Integer.toString(bir);
      BigInteger big = new BigInteger(temp);
      System.out.println(sifre(big.pow(5)));

   }
   public static int code ( int n) {
      int[] arr = new int[5];
      int index = 0;
      String temp = Integer.toString(n);
      String res = "" + temp.charAt(0) + temp.charAt(2)+temp.charAt(4)+temp.charAt(3)+temp.charAt(1);
      int rest = Integer.parseInt(res);

      return rest;

   }
   public static int sifre ( BigInteger n ) {
      String temp = n.toString();
      String res = "";

      for ( int i = temp.length() - 6; i <= temp.length() -1 ; i++) {

         res += temp.charAt(i);
      }
      String tempRes = res.substring(1);
      int sif =Integer.parseInt(tempRes);
      return sif;
   }
}

import java.io.*;
import java.util.Scanner;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		long n = in.nextLong();
		n = n / 10000 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 + (n / 10) % 10 * 10 + (n / 1000) % 10;
		// out.println(n);
		int i = 100000;
		long s;
		s = n * n * n * n;
		out.println(((s % i) * (n % i)) % i);

	}

	void run() {
		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}

}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {
        int num = in.nextInt();
        int d1 = num / 10000;
        int d2 = num / 1000 % 10;
        int d3 = num / 100 % 10;
        int d4 = num / 10 % 10;
        int d5 = num % 10;
        num = 10000 * d1 + 1000 * d3 + 100 * d5 + 10 * d4 + d2;
        out.println(modular(num, 5, 100000));
    }

    long modular(int a, int n, int m) {
        if (n == 0)
            return 1;
        else {
            int n2 = n / 2;
            long result = modular(a, n2, m);
            result = (result * result) % m;
            if (n % 2 == 1)
                result = (result * a) % m;
            return result;
        }
    }

    void run() {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    int z = in.nextInt();
    int a = z/10000;
    int b = z/1000 - a*10;
    int c = z/100 - a*100 - b*10;
    int d = (z%100)/10;
    int e = z%10;
    int z2 = a*10000 + c*1000 + e*100 + d*10 + b;
    long x1 = 1L*(((z2*z2)%100000)*z2)%100000;
    long x2 = ((((x1%100000)*z2)%100000)*z2)%100000;
    long x = x2%100000;
    System.out.println(x);
  }
}

import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    String s  = in.next();
 int a = s.charAt(0)-48;
 int b = s.charAt(1)-48;
 int c = s.charAt(2)-48;
 int d = s.charAt(3)-48;
 int e = s.charAt(4)-48;
 int k =a*10000+c*1000+e*100+d*10+b;

  BigInteger n = BigInteger.valueOf(k);
  n=n.pow(5);
   BigInteger m = BigInteger.valueOf(10000);
  n=n.mod(m);
  out.print(n);
   out.flush();
}
}

import java.io.*;
import java.util.*;

public class Main {
	void solve(Scanner in, PrintWriter out) {
		long a = in.nextInt();
		a = (a / 10000 % 10) * 10000 + (a / 100 % 10) * 1000 + (a % 10) * 100 + (a / 10 % 10) * 10 + (a / 1000 % 10);
		a = (a % 100000 * a % 100000 * a % 100000 * a % 100000 * a % 100000) % 100000;
		out.println(a % 100000);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}

}

import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.math.BigInteger;

public class A {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Solver solver = new Solver();
        solver.solve(1, in, out);

        out.close();
    }

    static class Solver {

        public static final double DD = 1.000000011;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long d = ((n / 10000) % 10) * 10000 + ((n / 100) % 10) * 1000 + (n % 10) * 100 + ((n / 10) % 10) * 10 + (n / 1000) % 10;
            BigInteger D = BigInteger.valueOf(d);
            D = D.pow(5);
            D = D.mod(BigInteger.valueOf(100000));

            out.println(D);
        }

    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

        public int[] nextIntArray(int size) {
            int[] result = new int[size];
            for (int i = 0; i < size; i++) {
                result[i] = nextInt();
            }
            return result;
        }

    }
}

import java.util.Scanner;

public class Zadacha {

	public static void main(String[] args) throws java.io.IOException{
		Scanner scan = new Scanner(System.in);
		int code = scan.nextInt();
		int d5 = code%10;
		int	d4 = code%100/10;
		int	d3 = code%1000/100;
		int	d2 = code%10000/1000;
		int	d1 = code/10000;

		int transformed_code = d1*10000 + d3*1000 + d5*100 + d4*10 + d2;
		long result = transformed_code*transformed_code%100000;

		for(int i = 0; i<3; i++) {
			result = result * transformed_code%100000;
		}

		d1 = (int)result/10000;
		d2 = (int)result%10000/1000;
		d3 = (int)result%1000/100;
		d4 = (int)result%100/10;
		d5 = (int)result%10;

		System.out.println(d1 +""+ d2 +""+ d3 +""+ d4 +""+ d5);
	}

}

import java.io.*;
import java.util.Scanner;

/**
 *
 * @author RIG
 */
public class AppPro {
    void solve(Scanner in,PrintWriter out){
        long a = in.nextInt();
        long i = a/10000;
        long ii = a/1000%10;
        long iii = a/100%10;
        long iv = a/10%10;
        long v = a%10;
        long p = i*10000+ iii *1000 + v*100+iv*10+ii;
        long res = Math.abs(((((p*p)%100000*p)%100000*p)%100000*p)%100000);
        out.println(res);

    }
    void run(){
        try ( Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);)
            {
                solve(in,out);
            }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new AppPro().run();
    }
}

import java.io.*;
import java.util.Scanner;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		long n = in.nextLong();
		n = n / 10000 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 + (n / 10) % 10 * 10 + (n / 1000) % 10;
		out.println(n);
		int i = 100000;
		long s;
		s = n * n * n * n;
		out.println(((s % i) * (n % i)) % i);

	}

	void run() {
		try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}

}

import java.io.*;

public class CF630L {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] cc = br.readLine().toCharArray();
		int n = (cc[0] - '0') * 10000 + (cc[2] - '0') * 1000 + (cc[4] - '0') * 100 + (cc[3] - '0') * 10 + (cc[1] - '0');
		long m = 1;
		for (int i = 0; i < 5; i++)
			m = m * n % 100000;
		System.out.println(m);
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Lcodf {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str,conv;
		int n;
		BigInteger a,b;
		str=br.readLine();
		conv="";
		conv+=str.charAt(0);
		conv+=str.charAt(2);
		conv+=str.charAt(4);
		conv+=str.charAt(3);
		conv+=str.charAt(1);
		b=new BigInteger(conv);
		a=b;
		a=a.multiply(b);
		a=a.multiply(b);
		a=a.multiply(b);
		a=a.multiply(b);
		b=new BigInteger("100000");
		a=a.mod(b);
		conv=""+a;
		if(conv.length()==5)
			System.out.println(conv);
		else
		{
			n=5-conv.length()+1;
			while(n-->0)
				System.out.print(0);
			System.out.println(conv);
		}
		br.close();
	}

}

/*
 * <first digit><third digit><fifth digit><fourth digit><second digit>
 */

import java.util.*;
import java.io.*;
public class CodeCracking
{

	/************************ SOLUTION STARTS HERE ************************/

	//DONT FORGET TO COMMIT AND PUSH TO GITHUB
	static long mod = (long)1e5;
	private static long modPow(long a,long b)   /* Modular exponentiation  */
	{
		if(b == 0L || a == 1L)
			return 1L;
		else if(b == 1L)
			return a;
		else
		{
			if((b & 1L) == 0L)  		//Checking whether b is even (fast)
				return modPow((a * a) % mod,b / 2L);
			else
				return (a * modPow((a * a) % mod,((b - 1L) / 2L))) % mod ;
		}
	}
	private static void solve(FastScanner s1, FastWriter out){

		char in[] = s1.nextLine().toCharArray();
		char num[] = new char[5];
		num[0] = in[0];
		num[1] = in[2];
		num[2] = in[4];
		num[3] = in[3];
		num[4] = in[1];
		long n = Long.parseLong(new String(num));
		long ans = modPow(n, 5L) % mod;
		out.print(ans);
	}

	/************************ SOLUTION ENDS HERE ************************/

	/************************ TEMPLATE STARTS HERE ************************/

	public static void main(String []args) throws IOException {
		FastScanner in  = new FastScanner(System.in);
		FastWriter  out = new FastWriter(System.out);
		solve(in, out);
		in.close();
		out.close();
	}

	static class FastScanner{
		public BufferedReader reader;
		public StringTokenizer st;
		public FastScanner(InputStream stream){
			reader = new BufferedReader(new InputStreamReader(stream));
			st = null;
		}
		public String next(){
			while(st == null || !st.hasMoreTokens()){
				try{
					String line = reader.readLine();
					if(line == null) return null;
					st = new StringTokenizer(line);
				}catch (Exception e){
					throw (new RuntimeException());
				}
			}
			return st.nextToken();
		}
		public String nextLine(){
			String str = null;
			try {
				str = reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}
		public void close(){
			try{ reader.close(); } catch(IOException e){e.printStackTrace();}
		}
	}
	static class FastWriter{
		BufferedWriter writer;
		public FastWriter(OutputStream stream){
			writer = new BufferedWriter(new OutputStreamWriter(stream));
		}
		public void print(int i) {
			print(Integer.toString(i));
		}
		public void println(int i) {
			print(Integer.toString(i));
			print('\n');
		}
		public void print(long i) {
			print(Long.toString(i));
		}
		public void println(long i) {
			print(Long.toString(i));
			print('\n');
		}
		public void print(double i) {
			print(Double.toString(i));
		}
		public void print(boolean i) {
			print(Boolean.toString(i));
		}
		public void print(Object o){
			print(o.toString());
		}
		public void println(Object o){
			print(o.toString());
			print('\n');
		}
		public void print(char i) {
			try{writer.write(i);} catch(IOException e){e.printStackTrace();}
		}
		public void print(String s){
			try{writer.write(s);} catch(IOException e){e.printStackTrace();}
		}
		public void println(String s){
			try{writer.write(s);writer.write('\n');} catch(IOException e){e.printStackTrace();}
		}
		public void println(){
			try{writer.write('\n');} catch(IOException e){e.printStackTrace();}
		}
		public void print(int arr[])
		{
			for (int i = 0; i < arr.length; i++) {
				print(arr[i]);
				print(' ');
			}
		}
		public void close(){
			try{writer.close();} catch(IOException e){e.printStackTrace();}
		}
	}

	/************************ TEMPLATE ENDS HERE ************************/
}

import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long arr[]=new long[5];
        for(int i=0;i<5;i++)
        {
            arr[4-i]=n%10;
  //          System.out.println(arr[4-i]);
            n=n/10;
        }
        n=arr[0];
        n=n*10+arr[2];
        n=n*10+arr[4];
        n=n*10+arr[3];
        n=n*10+arr[1];
        long sol=n;
        for(int i=0;i<4;i++)
        {
     //       System.out.println(sol);
            sol=(sol*n)%100000;
        }
        System.out.println(sol);

    }
}

import java.util.*;
import java.lang.*;
public class p630n{
	public static void main(String []args){
		Scanner s=new Scanner(System.in);
		int  i=s.nextInt();
		int a5=(i%10)*100,a4=((i/10)%10)*10,a3=((i/100)%10)*1000,a2=((i/1000)%10),a1=((i/10000)%10)*10000;
		a1+=a2+a3+a4+a5;
		int x=a1,h=4;
		while(h-->0){
			a1*=x;
			a1%=100000;
		}
		System.out.println(a1);

	}
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String s;
		s = sc.next();
		//System.out.println(s);
		char[] t = s.toCharArray();
		char[] w = s.toCharArray();
		t [ 1 ] = w [ 2 ];
		t [ 2 ] = w [ 4 ];
		t [ 3 ] = w [ 3 ];
		t [ 4 ] = w [ 1 ];
		String q = new String ( t );
		BigInteger b = new BigInteger(q);
		b = b.pow(5);
		b = b.mod(new BigInteger("100000"));
		System.out.println(b);
	}
}

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int c1 = n / 10000;
		int c2 = n / 1000 % 10;
		int c3 = n / 100 % 10;
		int c4 = n % 100 / 10;
		int c5 = n % 10;
		int k = c1 * 10000 + c3 * 1000 + c5 * 100 + c4 * 10 + c2;
		final int m = 100000;
		long s = (long) k * k % m * k % m * k % m * k % m;
		out.println(s);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {

			solve(in, out);
		}
	}

	public static void main(String args[]) {
		new Main().run();
	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class A {

	static int[] prime = {2, 3, 5, 7};

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.nextLine();
		num = num.substring(0, 1) + num.substring(2, 3) + num.substring(4)+num.substring(3, 4) + num.substring(1,2);
		BigInteger answer = new BigInteger(num);
		answer = answer.pow(5).mod(new BigInteger("100000"));
		num = answer.toString();

		System.out.println(answer);

	}

}

import java.util.Scanner;

public class Zadacha {

	public static void main(String[] args) throws java.io.IOException{
		Scanner scan = new Scanner(System.in);
		int code = scan.nextInt();
		int d5 = code%10;
		int	d4 = code%100/10;
		int	d3 = code%1000/100;
		int	d2 = code%10000/1000;
		int	d1 = code/10000;

		int transformed_code = d1*10000 + d3*1000 + d5*100 + d4*10 + d2;
		int result = transformed_code*transformed_code%100000;

		for(int i = 0; i<3; i++) {
			result = result * transformed_code%100000;

		}
		System.out.println(result);
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Lcodf {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str,conv;
		BigInteger a,b;
		str=br.readLine();
		conv="";
		conv+=str.charAt(0);
		conv+=str.charAt(2);
		conv+=str.charAt(4);
		conv+=str.charAt(3);
		conv+=str.charAt(1);
		b=new BigInteger(conv);
		a=b;
		a=a.multiply(b);
		a=a.multiply(b);
		a=a.multiply(b);
		a=a.multiply(b);
		b=new BigInteger("100000");
		a=a.mod(b);
		System.out.println(a);
		br.close();
	}

}

/*
 * <first digit><third digit><fifth digit><fourth digit><second digit>
 */

//package codeforce;

import java.math.BigInteger;
import java.util.Scanner;

/* @author Kbk*/
public class CrackingTheCode {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String num=sc.next();
        String num2="";
        num2=num2+num.charAt(0)+num.charAt(2)+num.charAt(4)+num.charAt(3)+num.charAt(1);
        BigInteger b=new BigInteger(""+num2);
        b=b.pow(5);
        System.out.println(b.mod(b.valueOf(100000)));
    }
}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int d1 = n / 10000;
        int d2 = n / 1000 % 10;
        int d3 = n / 100 % 10;
        int d4 = n / 10 % 10;
        int d5 = n % 10;
        int shuffled_n = d1 * 10000 + d3 * 1000 + d5 *100 + d4 *10 + d2;

        final int MOD = 100000;
        long result = shuffled_n;
        for (int i=0; i < 4; i++) {
            result = result*shuffled_n % MOD;
        }
        out.println(result % MOD);
    }

    int division_round_up(int dividend, int divisor) {
        return (dividend + (divisor - 1)) / divisor;
    }

    void run() {
        try (
            Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);
            ) {
            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

import java.util.*;
public class l {
	public static long mod = 100000;
	public static void main(String[] args){
		Scanner br = new Scanner(System.in);
		char[] arr = br.next().toCharArray();

		char[] res = new char[5];
		res[0] = arr[0];
		res[1] = arr[2];
		res[2] = arr[4];
		res[3] = arr[3];
		res[4] = arr[1];

		int suffle = Integer.parseInt(new String(res));
		System.out.println(pow(suffle, 5));
	}
	public static long pow(long base, int pow){
		if(pow == 0){
			return 1;
		}
		if(pow == 1){
			return base;
		}

		long res = pow(base, pow/2);
		res*=res;
		res%=mod;
		if(pow %2 == 1){
			res*=base;
		}
		res%=mod;
		return res;
	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class CF_630L {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int[] nums = new int[] {str.charAt(0)-'0',str.charAt(1)-'0',str.charAt(2)-'0',str.charAt(3)-'0',str.charAt(4)-'0'};
		BigInteger bi = BigInteger.valueOf(nums[0]*10000 + nums[2]*1000 + nums[4]*100 + nums[3]*10 + nums[1]*1);
		BigInteger sq = bi.multiply(bi);
		BigInteger ans = bi.multiply(sq.multiply(sq));
		ans = ans.mod(BigInteger.valueOf(100000));
		System.out.println(ans);

	}
}

import java.math.BigInteger;
import java.util.Scanner;

/**
 * Created by ruijie.yang on 3/8/16.
 */
public class CF630L {
    final static long MOD = 100000;

    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        while (scn.hasNext()){
            String in = scn.nextLine();
            String shuffle = ""+in.charAt(0)+in.charAt(2)+in.charAt(4)+in.charAt(3)+in.charAt(1);
            BigInteger pow = BigInteger.valueOf(Long.valueOf(shuffle)).pow(5);
            System.out.println(pow);
            int ans = pow.mod(BigInteger.valueOf(MOD)).intValue();
            System.out.println(String.format("%05d", ans));
        }
    }
}

import java.io.*;
import java.util.*;

public class Main {

    void solve(Scanner in, PrintWriter out) {

        long n = in.nextLong();
        long n1 = (n - n % 10000);
        long n2 = (n % 1000 - n % 100) * 10;
        long n3 = (n%10)*100;
        long n4 = n%100 - n%10;
        long n5 = (n / 1000) % 10;
        long number = (n2 + n3 + n4 + n5);

        System.out.println((number*number*number*number*number)%100000);

    }

    void run() {
        try ( Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class L_Volbit {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int[]per = {0,2,4,3,1};
        char[] line = in.next().toCharArray();
        char[]cur = new char[5];
        for(int i = 0; i < 5; i++){
            cur[i] = line[per[i]];
        }
        long v = Long.parseLong(new String(cur));
        long result = pow(v, 5, 100000);
        out.println(result);
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return (val * val) % MOD;
        } else {
            return (val * ((val * a) % MOD)) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int d1 = n / 10000,
			d2 = n / 1000 % 10,
			d3 = n / 100 % 10,
			d4 = n / 10 % 10,
			d5 = n % 10;
		int p = d1 * 10000 + d3 * 1000 + d5 * 100 + d4 * 10 + d2;
		final int q = 100000;
		// (a * b) % q = ((a % q) * (b % q)) % q
		// (p^5) % q = ((p^3 % q) * (p^2 % q)) % q = ((((p*p % q) * (p % q)) % q) * (((p % q) * (p % q)) % q)) % q
		out.print(((((p*p % q) * (p % q)) % q) * (((p % q) * (p % q)) % q)) % q);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}
	}

	public static void main(String args[])
	{
		new Main().run();
	}
}

/**
 *
 * @author sarthak
 */

import java.util.*;
import java.math.*;
import java.io.*;

public class ExpeEduRnd_L {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return "";
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);
    long n=s.nextLong();
    long nn=10000*(n/10000) + 1000*((n/100)%10) + 100*(n%10) + 10*((n/10)%10) + (n/1000)%10;
    long mod=100000;
    long a=((nn%mod)*(nn%mod))%mod;
    long d=((a%mod)*(a%mod))%mod;
    long ans=((d%mod)*(nn%mod))%mod;
    System.out.println(ans);

    }

}

import java.io.*;
import java.util.Scanner;

/**
 *
 * @author RIG
 */
public class AppPro {
    void solve(Scanner in,PrintWriter out){
        int a = in.nextInt();
        int i = a/10000;
        int ii = a/1000%10;
        int iii = a/100%10;
        int iv = a/10%10;
        int v = a%10;
        int p = i*10000+ iii *1000 + v*100+iv*10+ii;
        final int MOD = 100000;
        int res = p*p%MOD*p%MOD*p%MOD*p%MOD ;
        int res_i = res/10000;
        int res_ii = res/1000%10;
        int res_iii = res/100%10;
        int res_iv = res/10%10;
        int res_v = res%10;
        out.println(" " + res_i + res_ii + res_iii + res_iv + res_v);

    }
    void run(){
        try ( Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);)
            {
                solve(in,out);
            }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new AppPro().run();
    }
}

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String args[]) throws IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            long k = (n/10000)*10000 + ((n%1000)/100) * 1000 + (n%10) * 100 + ((n%100) / 10) * 10 + ((n / 1000) % 10);
            long res = k;
            for (int i = 1; i < 5; i++) {
                res *= k;
                res %= 100000;
            }
            out.println(res);
        }

    }

    static class InputReader {

        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.*;
import java.util.*;

public class Main {

	void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int d1 = n / 10000;
		int d2 = n / 1000 % 10;
		int d3 = n / 100 % 10;
		int d4 = n / 10 % 10;
		int d5 = n % 10;
		n = d1 * 10000 + d3 * 1000 + d5 * 100 + d4 * 10 + d2;

		int ans;
		ans = (((n * n % 100000 * n) % 100000 * n) % 100000 * n) % 100000;
		out.println(ans);
	}

	void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

import java.io.PrintWriter;
import java.util.Scanner;

public class Codeforces630L {

        private void solve(Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int nn = n / 10000 % 10 * 10000 + n / 1000 % 10 + n / 100 % 10 * 1000 + n / 10 % 10 * 10 + n % 10 * 100;
            int result = nn;
            result *= nn;
            result %= 100000;
            result *= nn;
            result %= 100000;
            result *= nn;
            result %= 100000;
            result *= nn;
            result %= 100000;
            out.println(result);
        }

        private void run() {
            try (Scanner in = new Scanner(System.in);
                 PrintWriter out = new PrintWriter(System.out)) {
                solve(in, out);
            }
        }

        public static void main(String[] args) {
            new Codeforces630L().run();
        }
}

import java.io.*;
import java.util.Scanner;
/**
 *
 * @author HP
 */
public class Main{
    void solve(Scanner in, PrintWriter out){
        int n = in.nextInt();
        int d1= n/10000;
        int d2 = n/1000%10;
        int d3 = n/100%10;
        int d4 = n/10%10;
        int d5 = n%10;
        final int MOD = 100000;
        long p  = d1*10000 + d3*1000 + d5*100 + d4*10 +d2;
        int r = (int)(p*p % MOD *p % MOD *p % MOD *p % MOD);
        out.println(r);

    }
    void run(){
        try (
            Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out);
                )
        {
            solve(in,out);
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new Main().run();
    }

}

import java.io.*;
import java.util.*;
import java.util.stream.IntStream;

public class B implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new B().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int gcd(int a, int b) {
        return a == 0 ? b : gcd(b % a, a);
    }

    int lcm(int a, int b) {
        return a / gcd(a, b) * b;
    }

    private void solve() {
        char[] s = readString().toCharArray();
        char[] t = new char[s.length];
        t[0] = s[0];
        t[1] = s[2];
        t[2] = s[4];
        t[3] = s[3];
        t[4] = s[1];
        long v = Long.parseLong(new String(t));
        long res = 1;
        for (int i = 0; i < 5; i++) {
            res = (res * v) % 100000;
        }
        out.println(res);
    }
}

import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    int z = in.nextInt();
    int a = z/10000;
    int b = z/1000 - a*10;
    int c = z/100 - a*100 - b*10;
    int d = (z%100)/10;
    int e = z%10;
    int z2 = a*10000 + c*1000 + e*100 + d*10 + b;
    int x = (((((((z2*z2)%100000)*z2)%100000)*z2)%100000)*z2)%100000;
    System.out.println(x);
  }
}

import java.io.*;
import java.util.StringTokenizer;

public class Main {

  private void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    int d1 = n / 10000;
    int d2 = n / 1000 % 10;
    int d3 = n / 100 % 10;
    int d4 = n / 10 % 10;
    int d5 = n % 10;
    long p = d1 * 10000 + d3 * 1000 + d5 * 100 + d4 * 10 + d2;
    final int MOD = 100000;
    int r = (int) (p * p % MOD * p % MOD * p % MOD * p % MOD);
    out.println(r);
  }

  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try (
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }

  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {

    }
  }

}

import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        // 12345
        // 71232
        int n = in.nextInt();

        int d1 = n / 10000;
        int d2 = (n/1000)%10;
        int d3 = (n/100)%10;
        int d4 = (n/10)%10;
        int d5 = n%10;

        // 13542
        int p = d1*10000 + d3*1000 + d5*100 + d4*10 + d2;
        final int MOD = 100000;
        // p^5 % 100000
        int r = (int)(p * p % MOD * p % MOD * p % MOD * p % MOD);
        int rd1= r / 10000;
        int rd2 = (r/1000)%10;
        int rd3 = (r/100)%10;
        int rd4 = (r/10)%10;
        int rd5 = r%10;

        System.out.println("" + rd1 + rd2 + rd3 +rd4 + rd5);
    }
}

import java.io.*;
import java.util.*;

public class Main {

	private void solve(Scanner in, PrintWriter out) {
		long n = in.nextLong();
		n = n / 10000 % 10 * 10000 + n / 100 % 10 * 1000 + n % 10 * 100 + n / 10 % 10 * 10 + n / 1000 % 10;
		long r = n;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		r = (r * n) % 100000;
		out.println(r);
	}

	private void run() {
		try (
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);) {

			solve(in, out);
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;
import java.io.BufferedWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.IOException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Alex
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskL solver = new TaskL();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskL {
        int g(char c) {
            return c - '0';
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
//        int n = in.readInt();
            char[] a = in.next().toCharArray();
            int shuff = g(a[0]) * 10000 +
                    g(a[2]) * 1000 +
                    g(a[4]) * 100 +
                    g(a[3]) * 10 +
                    g(a[1]);
            out.printLine(IntegerUtils.power(shuff, 5, 100000));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if(numChars == -1)
                throw new InputMismatchException();
            if(curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch(IOException e) {
                    throw new InputMismatchException();
                }
                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while(isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                if(Character.isValidCodePoint(c))
                    res.appendCodePoint(c);
                c = read();
            } while(!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if(filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class IntegerUtils {
        public static long power(long base, long exponent, long mod) {
            if(base >= mod)
                base %= mod;
            if(exponent == 0)
                return 1 % mod;
            long result = power(base, exponent >> 1, mod);
            result = result * result % mod;
            if((exponent & 1) != 0)
                result = result * base % mod;
            return result;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }
}

import java.util.*;
import java.math.*;

public class Main{

    public static String changeCharInPosition(int position, char ch, String str){
        char[] charArray = str.toCharArray();
        charArray[position] = ch;
        return new String(charArray);
    }

    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String n = scan.next();

        char tmp = n.charAt(1);
        n = changeCharInPosition(1, n.charAt(2), n);
        n = changeCharInPosition(2, tmp, n);

        tmp = n.charAt(2);
        n = changeCharInPosition(2, n.charAt(4), n);
        n = changeCharInPosition(4, tmp, n);

        BigInteger resp = new BigInteger(n);
        BigInteger md = new BigInteger("100000");
        resp = resp.pow(5);
        System.out.println(resp.mod(md));
    }
}

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int arr[] = new int[5];
        arr[0] = n/10000;
        arr[1] = n/100%10;
        arr[2] = n%10;
        arr[3] = n/10%10;
        arr[4] = n/1000%10;
        final int MOD = 100000;
        int num = arr[1]*1000+arr[2]*100+arr[3]*10+arr[4];
        num = num*num%MOD*num%MOD*num%MOD*num%MOD;
        System.out.println(num);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Template {

	public static void main(String[] args) throws IOException {

		Reader.init(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String x = Reader.next();

		StringBuilder sb = new StringBuilder();

		sb.append(x.charAt(0));
		sb.append(x.charAt(2));
		sb.append(x.charAt(4));
		sb.append(x.charAt(3));
		sb.append(x.charAt(1));

		int y = Integer.parseInt(sb.toString());
		long n = 1;
		long m = 1;
		n = (long) (Math.pow(y, 2) % 100000);
		m = (long) (Math.pow(y, 3) % 100000);

		out.println((n * m) % 100000);

		out.flush();
	}

	static class Reader {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		/** call this method to initialize reader for InputStream */
		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		/** get next word */
		static String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {

				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}

	}

}