import java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigInteger; public class No167 { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); BigInteger N = new BigInteger(br.readLine()); BigInteger M = new BigInteger(br.readLine()); BigInteger mod = new BigInteger("10"); System.out.println(N.modPow(M, mod)); } catch (Exception e) { System.err.println("Error:" + e.getMessage()); } } }