import scala.io.StdIn object Problem167 { def proc(N: String, M: String): Int = { val a = BigInt(N) val b = BigInt(M) a.modPow(b, 10).toInt } def main(args: Array[String]) { val N = StdIn.readLine() val M = StdIn.readLine() val result: Int = proc(N, M) println(result) } }