N = 4 N2 = 16 cost = [0] * (1 << N2) for bit in range(1 << N2): for x in range(N): for y in range(N): for dx, dy in [[0, 1], [1, 0]]: nx, ny = x + dx, y + dy if 0 <= nx < N and 0 <= ny < N: if ((bit >> (x * N + y)) & 1) != ((bit >> (nx * N + ny)) & 1): cost[bit] += 1 M = 220 dp = [[0] * (1 << N2) for _ in range(M)] dp[0][0] = 1 for bit in range(1 << N2): for i in range(N2): if ((bit >> i) & 1) == 0: nbit = bit | (1 << i) c = cost[nbit] for j in range(M - c): dp[j + c][nbit] += dp[j][bit] print(dp[int(input())][-1])