import java.util.*; import java.math.*; public class nmMod{ public static void main(String... args){ Scanner scan = new Scanner(System.in); String n = scan.next();int m = scan.nextInt(); BigInteger N = new BigInteger(n); BigInteger base = N.pow(m); BigInteger t = new BigInteger("10"); System.out.println(base.mod(t)); } }