L = int(input()) N = int(input()) k = (L-3) // 3 if k == 0: print(N) else: print(8 ** k * N)