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