To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a car, and an employee can choose one of four different car makes.

The parking lot before the office consists of one line of (2n - 2) parking spaces. Unfortunately the total number of cars is greater than the parking lot capacity. Furthermore even amount of cars of each make is greater than the amount of parking spaces! That's why there are no free spaces on the parking lot ever.

Looking on the straight line of cars the company CEO thought that parking lot would be more beautiful if it contained exactly n successive cars of the same make. Help the CEO determine the number of ways to fill the parking lot this way.


-----Input-----

The only line of the input contains one integer n (3 ≤ n ≤ 30) — the amount of successive cars of the same make.


-----Output-----

Output one integer — the number of ways to fill the parking lot by cars of four makes using the described way.


-----Examples-----
Input
3

Output
24


-----Note-----

Let's denote car makes in the following way: A — Aston Martin, B —   Bentley, M — Mercedes-Maybach, Z — Zaporozhets. For n = 3 there are the following appropriate ways to fill the parking lot: AAAB AAAM AAAZ ABBB AMMM AZZZ BBBA BBBM BBBZ BAAA BMMM BZZZ MMMA MMMB MMMZ MAAA MBBB MZZZ ZZZA ZZZB ZZZM ZAAA ZBBB ZMMM

Originally it was planned to grant sport cars of Ferrari, Lamborghini, Maserati and Bugatti makes but this idea was renounced because it is impossible to drive these cars having small road clearance on the worn-down roads of IT City.

Difficulty: MEDIUM_HARD
Tags: Combinatorics

Mathematics

Starter code:

Solutions:
n = int(input())
v = 2 * 3 * 4 ** (n - 3)
if n > 3:
	v += 9 * (n - 3) * 4 ** (n - 4)
print(4 * v)


n = int(input())
N = 2 * n - 2
ans = 0
for i in range(n):
	l_cnt = i
	r_cnt = N - i - n
	if r_cnt < 0:
		break
	m = 4
	p = int(l_cnt > 0) + int(r_cnt > 0)
	m *= 3 ** p
	l_cnt = max(0, l_cnt - 1)
	r_cnt = max(0, r_cnt - 1)
	p = l_cnt + r_cnt
	m *= 4 ** p
	ans += m
print(ans)


n = int(input())
result = (n - 3) * 4 ** (n - 4) * 3 * 3 * 4 + 2 * 4 ** (n - 3) * 3 * 4
print(int(result))


n = int(input())
ans = 2 * 3 * pow(4, n - 2) + (n - 3) * 9 * pow(4, n - 3)
print(ans)


from math import factorial as f
n = int(input())
print(4 ** (n - 3) * (9 * n - 3))


N = int(input())
print(4 * (2 * 3 * 4 ** (N - 3) + ((N - 3) * 3 * 3 * 4 ** (N - 4) if N > 3 else 0)))


import time
n = int(input())
start = time.time()
print(4 ** (n - 3) * 3 * (3 * n - 1))
finish = time.time()


n = int(input())
print(int(4 * (2 * 3 * pow(4, n - 3) + (n - 3) * 3 * 3 * pow(4, n - 4))))


n = int(input())
if n == 3:
	print(24)
else:
	print(2 * 3 * 4 ** (n - 3) * 4 + (n - 3) * 9 * 4 ** (n - 4) * 4)


import sys
import math

def main():
	n = int(input())
	ans = (n - 3) * (4 * 3 ** 2 * 4 ** (n - 4)) + 2 * (4 * 3 * 4 ** (n - 3))
	print(int(ans))
main()


n = int(input())
a = 24 * 4 ** (n - 3)
b = (n - 3) * 36 * 4 ** (n - 4)
print(int(a + b))


n = int(input())
if n > 3:
	print(4 * (6 * 4 ** (n - 3) + 9 * (n - 3) * 4 ** (n - 4)))
else:
	print(4 * (6 * 4 ** (n - 3)))


a = int(input())
b = 2 * a - 2
sum = 0
sum = 2 * 3 * pow(4, b - a)
sum += 3 * 3 * pow(4, b - a - 1) * (b - a - 1)
print(sum)


def binexpo(a, b):
	c = 1
	while b > 0:
		if b & 1:
			c *= a
		a *= a
		b >>= 1
	return c
n = int(input())
ans = 24 * binexpo(4, n - 3) + (n - 3) * (36 * binexpo(4, n - 4))
print(ans)


from math import factorial as f
n = int(input())
if n == 3:
	print(24)
else:
	print(2 * 4 * 3 * 4 ** (2 * n - n - 2 - 1) + (n - 3) * 4 * 3 * 3 * 4 ** (n - 4))


n = int(input())

def binpow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a
		a = a * a
		b >>= 1
	return res
out = 2 * 4 * 3 * binpow(4, n - 3) + (n - 3) * 4 * 3 ** 2 * binpow(4, n - 4)
print(out)


def binexpo(a, b):
	if b == 0:
		return 1
	res = binexpo(a, b // 2)
	if b % 2 == 1:
		return res * res * a
	else:
		return res * res
n = int(input())
n1 = binexpo(4, n - 2)
n2 = n1 // 4
ans = 6 * n1 + (n - 3) * 9 * n2
print(ans)


n = int(input())
print((n - 3) * 9 * 4 ** (n - 3) + 6 * 4 ** (n - 2))


n = int(input())

def binexp(a, b):
	ans = 1
	while b > 0:
		if b & 1 == True:
			ans = ans * a
		a = a * a
		b = b >> 1
	return ans
print((9 * n - 3) * binexp(4, n - 3))


def exp(a, n):
	pro = 1
	while n > 0:
		if n & 1:
			pro *= a
		n >>= 1
		a **= 2
	return pro
n = int(input())
if n == 2:
	print(4)
else:
	print((9 * n - 3) * exp(4, n - 3))


def sem_encostar(tam, colocar):
	posicoes_iniciais_validas = tam - colocar + 1
	if posicoes_iniciais_validas <= 2:
		return 0
	return posicoes_iniciais_validas - 2

def encostando(tam, colocar):
	return 2

def conta_tudo(colocar):
	tam = 2 * colocar - 2
	n = colocar
	return sem_encostar(tam, colocar) * 3 * 3 * 4 ** (n - 3) + encostando(tam, colocar) * 3 * 4 ** (n - 2)
print(conta_tudo(int(input())))


n = int(input())
print((9 * n - 3) * 4 ** (n - 3))


n = int(input())
a = n * 2 - 2
o = a - n
aa = 2 * 4 * 3 * 4 ** (o - 1)
bb = (o - 1) * 4 * 3 * 3 * 4 ** (o - 2)
ans = aa + (0 if o < 2 else bb)
print(ans)


def expo(x, y):
	res = 1
	while y > 0:
		if y & 1:
			res = res * x
		x = x * x
		y >>= 1
	return res
n = int(input())
res = expo(4, n - 3)
ans = 6 * (res * 4) + (n - 3) * 9 * res
print(ans)


from math import factorial
n = int(input())
print(int(2 * 3 * 4 * 4 ** (n - 3) + 3 * 3 * 4 * (n - 3) * 4 ** (n - 4)))


import sys
n = int(sys.stdin.readline())
m = (n - 3) * 9 * 4 ** (2 * n - 2 - (n + 2)) + 2 * 3 * 4 ** (2 * n - 2 - (n + 1))
print(int(4 * m))


n = int(input())
if n == 3:
	print(24)
	exit(0)
otv = 4 * (6 * 4 ** (n - 3) + (n - 3) * 9 * 4 ** (n - 4))
print(otv)


n = int(input())
print(int(24 * 4 ** (n - 3) + 36 * (n - 3) * 4 ** (n - 4)))


n = int(input())
ans = 0
w = n - 1
while w > 0:
	h = n - w - 1
	l = w - 1
	if h >= 1:
		t = 3 * 4 ** (h - 1)
	else:
		t = 1
	if l >= 1:
		t *= 3 * 4 ** (l - 1)
	ans += t
	w -= 1
ans *= 4
print(ans)


def pow(a, b):
	res = 1
	while b > 0:
		if b % 2 == 1:
			res = a * res
		a *= a
		b //= 2
	return res

def combinations(n):
	return pow(4, n - 3) * (9 * (n - 3) + 24)
n = int(input())
print(combinations(n))


n = int(input())
res = 0
res += 8 * (3 * pow(4, n - 3))
res += (n - 3) * 4 * 9 * int(pow(4, n - 4))
print(res)


def main():
	n = int(input())
	print(6 * 4 ** (n - 2) + (n - 3) * 9 * 4 ** (n - 3))
main()


n = int(input())
print(int(3 * 4 ** (n - 3) * (2 + 3 * (n - 1))))


import math
n = int(input())
print((3 * n - 1) * 3 * int(math.pow(4, n - 3)))


from math import factorial

def C(n, k):
	return n - k + 1
n = int(input())
if n != 3:
	print(4 * (C(2 * n - 2, n) - 2) * 3 * 3 * 4 ** (n - 4) + 4 * 2 * 3 * 4 ** (n - 3))
else:
	print(24)


n = int(input())
ans = 0
T = 2 * n - 2
t = 1
ans = 2 * 4 * 3 * 4 ** (T - n - 1)
if T - n - 2 >= 0:
	ans = ans + 4 * 3 * 3 * 4 ** (T - n - 2) * (T - n - 1)
print(ans)


n = 2 * int(input())
print(24 * (1 << n - 6) + (n > 6) * 36 * ((n >> 1) - 3) * (1 << max(n - 8, 0)))


import math

def choose(n, r):
	return math.factorial(n) // math.factorial(n - r) // math.factorial(r)

def choose2(n, r):
	return math.factorial(n) // math.factorial(n - r)
n = int(input())
result = int(4 * ((n - 3) * 3 ** 2 * 4 ** (n - 4) + 2 * 3 * 4 ** (n - 3)))
print(result)


def exp(a, b):
	res = 1
	while b > 0:
		if b % 2:
			res = res * a
		a = a * a
		b >>= 1
	return res

def main():
	n = int(input())
	print((n - 3) * 36 * exp(4, n - 4) + 24 * exp(4, n - 3))
main()


def exp(x, n):
	if n == 0:
		return 1
	res = exp(x, n // 2)
	if n % 2:
		return res * res * x
	else:
		return res * res

def find_combos(n):
	parking_slots = 2 * n - 2
	first_place_combos = 1 * 3 * exp(4, parking_slots - n - 1)
	last_place_combo = 1 * 3 * exp(4, parking_slots - n - 1)
	if parking_slots - n - 1 == 0:
		return first_place_combos * 2 * 4
	num_of_choosing_n_succ = parking_slots - n + 1
	middle_cases = num_of_choosing_n_succ - 2
	total_combos = 3 * 3 * middle_cases * exp(4, parking_slots - n - 2)
	return 4 * (first_place_combos + last_place_combo + total_combos)
n = int(input())
print(find_combos(n))


n = int(input())
res = 3 * 4 ** (n - 3) * (3 * n - 1)
print(res)


n = int(input())
if n == 2:
	print(4)
elif n == 3:
	print(24)
else:
	print(4 * 2 * 3 * 4 ** (n - 3) + 4 * (n - 3) * 3 ** 2 * 4 ** (n - 4))


n = open(0).readlines()
n = int(n[0])
result = 4 ** (n - 3) * 24 + (n - 3) * 3 ** 2 * 4 * 4 ** (n - 4)
print(int(result))


n = int(input())
print(4 * ((n - 3) * 3 * 3 * 4 ** max(0, n - 4) + 2 * 3 * 4 ** (n - 3)))


n = int(input())
w = 2 * n - 2
res = 2 * 3 * pow(4, w - n - 1, 999999999999999999)
res += (w - n - 1) * 3 * 3 * pow(4, w - n - 2, 9999999999999999)
res *= 4
print(res)


n = int(input())
tot = 2 * n - 2
ans = 0
for i in range(tot - n + 1):
	p = 4
	l = 1 + i
	if l > 1:
		p = p * 3
	for j in range(100):
		if 1 + j < l - 1:
			p = p * 4
	if l + n - 1 < tot:
		p = p * 3
	for j in range(100):
		if tot - j > l + n:
			p = p * 4
	ans = ans + p
print(ans)


a = int(input())
total = 0
total += int(4 * 2 * 3 * 4 ** (a - 3))
total += int(4 * (a - 3) * 3 * 3 * 4 ** (a - 4))
print(total)


from sys import stdin
k = int(stdin.readline())
n = 2 * k - 2
result = (n - (k + 2) + 1) * 4 * 3 * 3 * 4 ** (n - (k + 2)) + 1 * 4 * 3 * 4 ** (n - (k + 1)) * 2
print(int(result))


def main():
	n = int(input())
	sol = 2 * 4 * 3 * 4 ** (n - 3)
	if n >= 4:
		sol += (n - 3) * 4 * 3 ** 2 * 4 ** (n - 4)
	print(sol)

def fast_pow(a, b):
	if b == 0:
		return 1
	res = fast_pow(a, b // 2)
	if b % 2 == 0:
		return res * res
	return res * res * a
main()


n = int(input())
print(4 * (2 * 3 * (1 << 2 * n - 6) + (n - 3) * 3 * 3 * (1 << max(0, 2 * n - 8))))


import sys
input = sys.stdin.readline
from collections import deque
n = int(input())
c = 2 * 3 * 4 * pow(4, n - 3)
for i in range(0, n - 3):
	c += 4 * 3 * 3 * (pow(4, i) * pow(4, n - i - 4))
print(max(c, 1))


n = int(input())
ans = 24 * pow(4, n - 3)
if n >= 4:
	ans += (n - 3) * 36 * pow(4, n - 4)
print(ans)


n = int(input())
x = (n - 3) * 9 * 4 ** (n - 3)
y = 6 * 4 ** (n - 2)
print(x + y)


def binPow(a, b):
	if b == 0:
		return 1
	else:
		res = binPow(a, int(b / 2))
		if b % 2 == 0:
			return res * res
		else:
			return res * res * a
n = int(input())
print(4 * 3 * binPow(4, n - 3) * 2 + 4 * 9 * (n - 3) * binPow(4, n - 4))


import os, sys, pdb
import time, calendar, datetime
import math, itertools
import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom
(n,) = list(map(int, input().split()))
print(2 * 4 * 3 * 4 ** max(0, n - 3) + (n - 3) * 4 * 9 * 4 ** max(0, n - 4))


n = int(input())
k = 2 * n - 2 - n
ans = 0
for i in range(k + 1):
	if i == 0:
		ans += 3 * 4 ** (k - 1)
	elif i == k:
		ans += 3 * 4 ** (i - 1)
	else:
		ans += 3 * 3 * 4 ** (i - 1) * 4 ** (k - i - 1)
print(ans * 4)


n = int(input())

def pow(n, index):
	return int(n ** index)
ans = 2 * (4 * 3 * pow(4, n - 3))
ans += (n - 3) * (4 * (3 * 3) * pow(4, n - 4))
print(ans)


import sys
import math
from collections import deque
from bisect import bisect_left, bisect_right
I = sys.stdin.readline
II = lambda : int(I())
IN = lambda x: map(int, x.split())
L = lambda x: list(IN(x))
M = 1000000007
P = print
n = II()
a = pow(4, n - 3)
res = 4 * (6 * a + (n - 3) * (9 * (a // 4)))
P(res)


x = int(input())
print(int(24 * 4 ** (x - 3) + (x - 3) * 36 * 4 ** (x - 4)))


n = int(input())
u = 4 * 3 * 4 ** (n - 3) * 2
if n > 3:
	u += 4 * (n - 3) * 9 * 4 ** (n - 4)
print(u)


a = int(input())
print(4 ** (a - 3) * 3 * (3 * a - 1))


n = int(input())
total = 2 * n - 2
mul_e = 3
mul_b = 9
diff = total - n + 1
for i in range(1, total - n):
	mul_e *= 4
for i in range(2, total - n):
	mul_b *= 4
print(2 * 4 * mul_e + (diff - 2) * 4 * mul_b)


N = int(input())
sol = 0
i = 0
while i + N - 1 < 2 * N - 2:
	restL = i
	tmp = 1
	if restL >= 1:
		tmp *= 3
		restL -= 1
	if restL >= 0:
		tmp *= 4 ** restL
	restR = 2 * N - 2 - (i + N - 1) - 1
	if restR >= 1:
		tmp *= 3
		restR -= 1
	if restR >= 0:
		tmp *= 4 ** restR
	sol += tmp
	i += 1
print(4 * sol)


n = int(input())
cap = 2 * n - 2
ans = 2 * (12 * 4 ** (n - 3))
tmp = n - 4
if tmp >= 0:
	ans += (tmp + 1) * (36 * 4 ** tmp)
print(ans)


n = int(input()) - 3
print(3 * 4 ** n * (8 + 3 * n))


def fexp(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans
n = int(input())
if n == 3:
	print(24)
else:
	mid = (n - 3) * 9 * fexp(4, n - 3)
	side = 6 * fexp(4, n - 2)
	print(mid + side)


n = int(input())
r1 = int((n - 3) * 4 * 9 * 4 ** (2 * n - 2 - n - 2))
r2 = int(2 * 4 * 3 * 4 ** (2 * n - 2 - n - 1))
print(r1 + r2)


n = int(input())
slots = 2 * n - 2
starts = slots // 2
permutations_border = 3 * 4 ** (n - 2 - 1)
permutations = 4 ** (n - 2 - 2) * 3 * 3
r = 4 * ((starts - 2) * permutations + 2 * permutations_border)
print(int(r))


from math import factorial as fac

def solve():
	n = int(input())
	m = 2 * n - 2
	i = 2
	ans = 0
	while i + n - 1 <= m - 1:
		p = max(0, m - n - 2)
		ans += 4 * 3 * 3 * 4 ** p
		i += 1
	ans += 2 * 4 * 3 * 4 ** max(0, m - n - 1)
	print(ans)
solve()


n = int(input())
ans = 0
for i in range(n - 1):
	t = 4
	if i > 0:
		t = t * 3 * 4 ** (i - 1)
	if i + 1 < n - 1:
		t = t * 3 * 4 ** (n - i - 2 - 1)
	ans += t
print(ans)


import sys, math
inputs = iter(sys.stdin.readlines())
n = int(next(inputs))
print(int(2 * 4 * 3 * pow(4, n - 3) + (n - 3) * 4 * 3 ** 2 * pow(4, n - 4)))


def iter_pow(x, n):
	res = 1
	while n:
		if n & 1:
			res = res * x
		x = x * x
		n = n >> 1
	return res
num = int(input())
pw = iter_pow(4, num - 3)
print(24 * pw + 36 * (num - 3) * pw // 4)


n = int(input())
e1 = 24 * int(4 ** (n - 3))
e2 = (n - 3) * 4 * 9 * int(4 ** (n - 4))
print(e1 + e2)


def bin_expo(b, p):
	res = 1
	while p > 0:
		if p & 1:
			res = res * b
		b = b * b
		p = p >> 1
	return res
n = int(input())
res = bin_expo(4, n - 3)
res = res * (n * 9 - 3)
print(int(res))


def pow(a, b):
	ans = 1
	while b:
		if b % 2:
			ans = ans * a
		a = a * a
		b = b >> 1
	return ans
n = int(input())
if n - 4 >= 0:
	print(2 * 3 * 4 * pow(4, n - 3) + (n - 3) * 4 * 3 * 3 * pow(4, n - 4))
else:
	print(2 * 3 * 4 * pow(4, n - 3))


n = int(input())
ans = 2 * 4 * 3 * 4 ** (n - 3)
if n > 3:
	ans += (n - 3) * 3 * 3 * 4 ** (n - 4) * 4
print(ans)


n = int(input())
L = n + n - 2
S = 4 * 3 * 2 * 4 ** (L - n - 1)
for i in range(1, L - n):
	S += 3 * 4 * 3 * 4 ** (L - n - 2)
print(S)


import sys
import math

def main():
	n = int(sys.stdin.readline().strip())
	print(4 ** (n - 3) * (9 * n - 3))
main()


n = int(input())
ans = 3 * (3 * n - 1) * 4 ** (n - 3)
print(ans)


n = [int(x) for x in input().split()][0]
if n == 3:
	print(24)
else:
	print((9 * n - 3) * 4 ** (n - 3))


N = int(input())
print(int(4 * (2 * 3 * 4 ** (N - 3) + 3 * 4 ** (N - 4) * 3 * (N - 3))))


from math import *
n = int(input())
var = pow(4, n - 3)
var1 = pow(4, n - 4)
print(int(4 * 3 * 2 * var + (n - 3) * 3 ** 2 * 4 * var1))


from math import factorial as f

def c(n, k):
	return f(n) // f(k) // f(n - k)
n = int(input())
fs = 4 ** (n - 3) * 3 * 4
sec = 0
if n > 3:
	sec = 4 * (n - 3) * 9 * 4 ** (n - 4)
print(2 * fs + sec)


NUM_CAR_MAKES = 4

def total_num_cars(n: int) -> int:
	return 2 * n - 2

def count_ways(n: int) -> int:
	line_on_end = 2 * NUM_CAR_MAKES * (NUM_CAR_MAKES - 1) * NUM_CAR_MAKES ** (total_num_cars(n) - n - 1)
	not_line_on_end = (total_num_cars(n) - n - 1) * NUM_CAR_MAKES * (NUM_CAR_MAKES - 1) ** 2 * NUM_CAR_MAKES ** (total_num_cars(n) - n - 2)
	return int(line_on_end + not_line_on_end)
print(count_ways(int(input())))


n = int(input().strip())
r = 24 * 4 ** (n - 3)
if n > 3:
	r += (n - 3) * 36 * 4 ** (n - 4)
print(r)


def pow(a, b):
	res = 1
	while b > 0:
		if b & 1 == 1:
			res = res * a
		a = a * a
		b = b >> 1
	return res

def main():
	n = int(input())
	sol = 3 * pow(4, n - 3) * (3 * n - 1)
	print(sol)
main()


n = int(input())
print(3 * (3 * n - 1) * pow(2, 2 * n - 6))


import sys
n = int(sys.stdin.readline())
ret = 3 * 4 ** (n - 3) * (3 * n - 1)
print(ret)


def exp(a, b):
	r = 1
	while b > 0:
		if b % 2:
			r *= a
		a *= a
		b //= 2
	return r
n = int(input())
slots = 2 * n - 2
starts = slots // 2
permutations_border = 3 * exp(4, n - 3)
permutations = permutations_border // 4 * 3
r = 4 * ((starts - 2) * permutations + 2 * permutations_border)
print(int(r))


import math
n = int(input())
t1 = (n - 3) * 36 * 4 ** (n - 4)
t2 = 24 * 4 ** (n - 3)
print(math.floor(t1 + t2))


n = int(input())
ans = 0
l = 2 * n - 2
for x in range(0, l - n + 1):
	t = 4
	for y in range(0, l):
		if x <= y and y < x + n:
			continue
		elif y == x - 1 or y == x + n:
			t *= 3
		else:
			t *= 4
	ans += t
print(ans)


def binpow(a, n):
	res = 1
	while n > 0:
		if n & 1:
			res = res * a
		a = a * a
		n >>= 1
	return res
n = int(input())
print(2 * 4 * 3 * binpow(4, n - 3) + (n - 3) * 4 * 9 * binpow(4, n - 4))


def find(n):
	front = pow(4, n - 3)
	end = pow(4, n - 4)
	res = 24 * front + 36 * (n - 3) * end
	print(int(res))
n = int(input())
find(n)


def binpow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a
		a = a * a
		b >>= 1
	return res
n = int(input())
cap = 2 * n - 2
ans = 2 * (12 * binpow(4, n - 3))
tmp = n - 4
if tmp >= 0:
	ans += (tmp + 1) * (36 * binpow(4, tmp))
print(ans)


n = int(input())
print(int(6 * pow(4, n - 2) + 36 * (n - 3) * pow(4, n - 4)))


n = int(input())
total = 2 * n - 2
if n == 3:
	print(24)
else:
	free = total - n - 2 + 1
	ans = 0
	ans += 4 * 2 * 3 * pow(4, total - n - 1)
	left = 2
	while left < total - n + 1:
		ans += 4 * 3 * 3 * pow(4, left - 2) * pow(4, total - left - n)
		left += 1
	print(ans)


n = int(input())
if n - 1 == 1:
	print(4)
elif n - 1 == 2:
	print(3 * 2 * 4)
else:
	print((n - 3) * 3 * 3 * 4 ** (n - 4) * 4 + 2 * 4 * 3 * 4 ** (n - 3))


def power(a, b):
	ans = 1
	while b > 0:
		if b & 1:
			ans = ans * a
		a = a * a
		b >>= 1
	return ans
n = int(input())
en = 4 * 3 * power(4, n - 3)
mid = 4 * 3 ** 2 * power(4, n - 4)
ans = 2 * en + (n - 3) * mid
print(ans)


n = int(input())
ans = 4 ** (n - 2) * 6
for i in range(1, n - 2):
	ans = ans + 9 * 4 ** (n - 3)
print(ans)


n = int(input())
l = 2 * n - 2
s = 0
k = n
if k < l - 1:
	d1 = (l - (k + 2) + 1) * 9 * 4 ** (l - 2 - k)
else:
	d1 = 0
d2 = 2 * 3 * 4 ** (l - 1 - k)
s += d1 + d2
print(s * 4)


from functools import reduce
from math import factorial
n = int(input())
print(int((n - 3) * 4 * 9 * 4 ** (n - 4) + 2 * 4 * 3 * 4 ** (n - 3)))


n = int(input())
l = 2 * n - 2
t = l - n
cur1 = 4 ** t * 3
cur2 = 0
if t >= 2:
	cur2 += 4 ** (t - 1) * 9
print(cur1 * 2 + (t - 1) * cur2)


n = int(input())
res = 0
res += 4 * 3 * int(pow(4, 2 * n - 2 - (n + 1))) * 2
res += 4 * 3 * 3 * int(pow(4, 2 * n - 2 - (n + 2))) * (n - 3)
print(res)


n = int(input())
extremes = 3 * pow(4, n - 2)
mid = 3 ** 2 * pow(4, n - 3)
ans = 2 * extremes + (n - 3) * mid
print(ans)


from math import factorial as fac
n = int(input())
a = 24 * 4 ** (n - 3) + (n - 3) * 36 * 4 ** (n - 4)
print(int(a))


def exponent(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a
		a = a * a
		b = b >> 1
	return res
n = int(input())
ans = 0
park = 2 * n - 2
if park >= 3:
	total_4 = park - (n - 1)
	gap = park - (n - 1)
	ans += 2 * exponent(4, gap - 1) * 3
	total_4 -= 2
	if total_4:
		ans += 3 * 3 * exponent(4, gap - 2) * total_4
	print(ans)


def pow(n, p):
	ans = 1
	while p > 0:
		if p & 1:
			ans *= n
		n *= n
		p >>= 1
	return ans
n = int(input())
s = 0
m = 0
if n - 3 >= 0:
	s = 2 * 4 * 3 * pow(4, n - 3)
if n - 4 >= 0:
	m = 4 * 3 * 3 * pow(4, n - 4) * (n - 3)
print(s + m)


import math
from collections import deque
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
a = 0
l = 0
r = n - 2
for i in range(n - 1):
	if l == 0:
		lf = 1
	else:
		lf = 3 * pow(4, l - 1)
	if r == 0:
		rf = 1
	else:
		rf = 3 * pow(4, r - 1)
	l += 1
	r -= 1
	a += 4 * rf * lf
print(a)


def num(n):
	if n == 2:
		return 4
	elif n > 2 and n < 3:
		return 6 * pow(4, n - 2)
	else:
		return 6 * pow(4, n - 2) + 9 * pow(4, n - 3) * (n - 3)
n = int(input())
print(num(n))


n = int(input())

def pwr(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a
		a = a * a
		b = b >> 1
	return res
k = pow(4, n - 4)
print(int(2 * 4 * 3 * 4 * k + (n - 3) * 4 * 3 * 3 * k))


def avtostoyanka(n):
	return int(2 * 4 * 3 * 4 ** (n - 3) + (n - 3) * 4 * 3 * 3 * 4 ** (n - 4))
print(avtostoyanka(int(input())))


def binpow(a, n, m):
	if n == 0:
		return 1
	x = binpow(a, n // 2, m)
	x = x * x % m
	if n % 2 == 1:
		x = x * a % m
	return x

def binpow1(a, n, m):
	r = 1
	while n > 0:
		if n & 1:
			r = r * a % m
		a = a * a % m
		n = n >> 1
	return r
n = int(input())
ans = 0
if n > 3:
	ans += 36 * (n - 3) * pow(4, n - 4)
ans += 24 * pow(4, n - 3)
print(ans)


n = int(input())
x = 2 * 4 * 3 * 4 ** (n - 3)
y = (n - 3) * 4 * 3 ** 2 * 4 ** (n - 4)
print(int(x + y))


n = int(input())
if n == 3:
	print(24)
else:
	res = 2 * 4 * 3 * 4 ** (n - 3)
	res += (n - 3) * 4 * 3 * 3 * 4 ** (n - 4)
	print(res)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
ans = 2 * (4 ** (n - 2) * 3) + (n - 3) * (3 ** 2 * 4 ** (n - 3))
print(ans)


n = int(input())
a = 2 * 3 * 4 ** (n - 3)
b = (n - 3) * 3 * 3 * 4 ** (n - 4)
res = (a + b) * 4
print(int(res))


n = int(input())
p = n + n - 2
r = 0
for i in range(1, p - n + 2):
	if i == 1 or i == p - n + 1:
		r += 4 * 3 * pow(4, p - n - 1)
		continue
	r += 4 * 3 * 3 * pow(4, p - n - 2)
print(r)


import sys

def fact(k):
	return k ** 2 * (k - 1) ** 2 * (k - 2) ** 2 * (k - 3) ** 2 * (k - 4) ** 2
n = int(input())
print(4 ** (n - 3) * 3 * (8 + 3 * (n - 3)))


def binexpo(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a
		a = a * a
		b = b >> 1
	return res
n = int(input())
x = 2 * 4 * 3 * binexpo(4, n - 3)
y = (n - 3) * 4 * 3 ** 2 * binexpo(4, n - 4)
print(x + y)


n = int(input())

def foo(n):
	res = 0
	res += 4 * 3 * 4 ** (n - 3)
	res += 4 * 3 * 4 ** (n - 3)
	if n > 3:
		res += 36 * 4 ** (n - 4) * (n - 3)
	return res
print(foo(n))


n = int(input())
print(3 * (3 * n - 1) * pow(4, n - 3))


n = int(input())
ways_count = max((n - 3) * 36 * 4 ** (n - 4), (n - 3) * 36)
ways_count += 2 * (3 * 4 ** (n - 3)) * 4
print(int(ways_count))


n = int(input())
ans = 0
for i in range(0, 2 * n - 2 - n + 1):
	if i == 0 or i == 2 * n - 2 - n:
		ans += 4 * 3 * 4 ** (2 * n - 2 - n - 1)
	else:
		ans += 4 * 3 * 3 * 4 ** (2 * n - 2 - n - 2)
print(ans)


n = int(input())
spaces = [0] * (2 * n - 2)
i = 1
j = n
cnt = 12 * 4 ** max(0, 2 * n - 2 - n - 1)
while j < 2 * n - 2:
	fnt = i
	bck = 2 * n - 2 - (j + 1)
	if bck > 0:
		cnt = cnt + 4 * 3 * 4 ** (i - 1) * 3 * 4 ** (bck - 1)
	else:
		cnt += 4 * 3 * 4 ** (i - 1)
	i += 1
	j += 1
print(cnt)


def main():
	n = int(input())
	p1 = 24 * 4 ** (n - 3)
	p2 = (n - 3) * 4 * 9 * 4 ** max(0, n - 4)
	print(p1 + p2)
main()


n = int(input())
all = 2 * (n - 1)
print(int(4 * (2 * 3 * pow(4, all - n - 1) + (n - 3) * 3 * 3 * pow(4, all - n - 2))))


n = int(input())

def pow(a, n):
	if n < 0:
		return 0
	if n == 0:
		return 1
	if n % 2 == 0:
		x = pow(a, n // 2)
		return x * x
	else:
		x = pow(a, (n - 1) // 2)
		return x * x * a
ans = 2 * (4 * 3 * pow(4, n - 3))
ans += (n - 3) * (4 * (3 * 3) * pow(4, n - 4))
print(ans)


def powe(b, p):
	n = 0
	s = 1
	while p != 0:
		if p % 2:
			s = s * b
		b = b * b
		p = p // 2
	return s
n = int(input())
x = 2 * n - 2
if n == 2:
	print(4)
else:
	print(2 * 3 * powe(4, x - n) + 9 * (x - n - 1) * powe(4, x - n - 1))


n = int(input())
ans = 0
cnt = 2 * n - 2
ans += (n - 3) * 4 * 3 * 3 * 4 ** (cnt - n - 2)
ans += 4 * 3 * 4 ** (cnt - n - 1) * 2
print(int(ans))


n = int(input().strip())
print(2 * 3 * 4 ** (n - 2) + 9 * (n - 3) * 4 ** (n - 3))


n = int(input())
otherPlaces = 2 * n - 2 - n
endings = 2 * 4 * (4 ** (otherPlaces - 1) * 3)
middle = 4 * max(2 * n - 4 - n + 1, 0) * 3 * 3 * 4 ** (otherPlaces - 2)
print(int(endings + middle))


n = int(input())
a = 3 * 4 ** (2 * n - 2 - n - 1)
b = 9 * 4 ** (2 * n - 2 - n - 2)
print(int(2 * a + b * (n - 3)) * 4)


n = int(input())
if n - 4 >= 0:
	print(2 * 3 * 4 * 4 ** (n - 3) + (n - 3) * 4 * 3 * 3 * 4 ** (n - 4))
else:
	print(2 * 3 * 4 * 4 ** (n - 3))


def power(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a
		a = a * a
		b >>= 1
	return res
n = int(input())
four_power = power(4, n - 3)
print(24 * four_power + 36 * (n - 3) * (four_power // 4))


def func(p, a):
	res = 1
	while p > 0:
		if p & 1:
			res = res * a
		a = a * a
		p >>= 1
	return res
n = int(input())
power = func(n - 3, 4)
side = 4 * 3 * power
middle = 3 * 3 * power
print(2 * side + (n - 3) * middle)


n = int(input())
gen = 0
if n - 4 >= 0:
	gen = (n - 3) * 4 * 3 * 3 * pow(4, n - 4)
cor = 2 * 4 * 3 * pow(4, n - 3)
print(gen + cor)


n = int(input())
pos = n - 1
rem = n - 2
ans = 4 * (2 * (3 * pow(4, rem - 1)) + (pos - 2) * (9 * pow(4, rem - 2)))
print(int(ans))


n = int(input())
res = pow(4, n - 2) * 6
res += (n - 3) * pow(4, n - 3) * 9
print(res)


def mod_exp(a, b):
	if b == 0:
		return 1
	res = 1
	while b > 0:
		if b & 1:
			res = res * a
		a = a * a
		b = b >> 1
	return res
n = int(input())
ans = 2 * 4 * 3 * mod_exp(4, n - 3)
ans += (n - 3) * 4 * 9 * mod_exp(4, n - 4)
print(ans)


n = int(input())
ans = 0
ans += int(2 * 3 * 4 ** (n - 3))
ans += int((n - 3) * 3 * 3 * 4 ** (n - 4))
ans *= 4
print(ans)


n = int(input())
Count = 0
if n == 3:
	Count = 24
else:
	Count = 2 * 3 * 4 ** (2 * n - 2 - n - 1)
	Count += Count * 3 // 8 * (n - 3)
	Count *= 4
print(Count)


import sys

def fact(n):
	ret = 1
	for x in range(1, n + 1):
		ret = ret * x
	return ret

def C(n, k):
	return fact(n) // (fact(k) * fact(n - k))

def get(n):
	if n == 0:
		return 1
	if n == 1:
		return 3
	return 3 * 4 ** (n - 1)
n = int(input())
ret = 0
ans = 0
for x in range(n - 2 + 1):
	right = n - 2 - x
	left = x
	ans += 4 * get(left) * get(right)
print(ans)


n = int(input())
m = max(0, n - 3) * 4 ** (n - 3) * 9 + 2 * 4 ** (n - 2) * 3
print(m)


import sys
import os
from io import BytesIO, IOBase

def cel(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict
for _ in range(1):
	n = ii()
	res = 6 * pow(4, n - 2) + 9 * (n - 3) * pow(4, n - 3)
	print(res)


import math
n = int(input())
summ = 0
summ += int(4 ** (2 * n - 2 - n - 1)) * 3 * 4 * 2
summ += int(4 ** (2 * n - 2 - n - 2)) * 3 * 3 * 4 * (2 * n - 2 - n - 1)
print(summ)


import math
n = int(input())
ans = 0
for i in range(2 * n - 2 - n + 1):
	cur = 4
	if i == 1:
		cur *= 3
	elif i > 1:
		cur *= 3 * pow(4, i - 1)
	if i == 2 * n - 2 - n - 1:
		cur *= 3
	elif i <= 2 * n - 2 - n - 2:
		cur *= 3 * pow(4, 2 * n - 2 - i - n - 1)
	ans += cur
print(ans)


n = int(input())
answer = 4 * (3 * 4 ** (n - 3) * 2 + (n - 3) * 3 * 3 * 4 ** (n - 4))
print(int(answer))


ans = 0
n = int(input())
for i in range(1, n):
	p = 2 * n - 2 - i - n + 1
	q = i - 1
	if p >= 1:
		p = 3 * 4 ** (p - 1)
	else:
		p = 1
	if q >= 1:
		q = 3 * 4 ** (q - 1)
	else:
		q = 1
	ans += 4 * p * q
print(ans)


a = int(input())
r = a - 2
edge = 2 * 4 ** r * 3
others = 4 ** (r - 1) * 9 * (r - 1)
print(edge + others)


import re, sys, string, operator, functools, fractions, collections
sys.setrecursionlimit(10 ** 7)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
RI = lambda x=' ': list(map(int, input().split(x)))
RS = lambda x=' ': input().rstrip().split(x)
mod = int(1000000000.0 + 7)
eps = 1e-06
n = RI()[0]
a = (9 * (n - 3) + 24) * 4 ** (n - 3)
print(a)


N = int(input())
ans = 4
Sum = 0
if N - 3 >= 0:
	Sum += 2 * 3 * 4 ** (N - 3)
if N - 4 >= 0:
	Sum += (N - 3) * 3 ** 2 * 4 ** (N - 4)
if Sum > 0:
	ans *= Sum
print(ans)


n = int(input())
n = n - 3
sp = 2 * (n - 1)
print(3 * 4 ** n * (8 + 3 * n))


n = int(input())
answer = 1
answer = answer * 3
answer = answer * (3 * n - 1)
for i in range(n - 3):
	answer = answer * 4
print(answer)


a = int(input())
print(int(4 * (2 * 3 * 4 ** (a - 3) + (a - 3) * 3 * 3 * 4 ** (a - 4))))


n = int(input())
ans = 0
for i in range(2 * n - 2):
	for j in range(2 * n - 2):
		if i + n - 1 == j:
			cur = 4
			if i >= 1:
				cur *= 3
				cur *= 4 ** (i - 1)
			if j + 1 < 2 * n - 2:
				cur *= 3
				cur *= 4 ** (2 * n - j - 4)
			ans += cur
print(ans)


import sys
n = int(input())
makes = 4
middle_start = makes * (n - 3) * (makes - 1) ** 2
if n > 4:
	middle_start *= pow(makes, n - 4)
edge_start = 2 * makes * (makes - 1)
if n > 3:
	edge_start *= pow(makes, n - 3)
print(middle_start + edge_start)


def super_pow(x, y):
	res = 1
	while y > 0:
		if y & 1:
			res *= x
		x **= 2
		y >>= 1
	return res
n = int(input())
answer = 2 * 3 * 4 * super_pow(4, n - 3)
if n == 3:
	print(answer)
else:
	answer += 4 * 9 * (n - 3) * super_pow(4, n - 4)
	print(answer)


import math

def cars(n):
	return int(2 * 4 * 3 * math.pow(4, n - 3) + (n - 3) * 4 * 9 * math.pow(4, n - 4))
n = int(input())
print(cars(n))


n = int(input())
total_ways = 2 * n - 2 - n + 1
ans = 4 * (2 * 3 * pow(4, 2 * n - 2 - n - 1) + (total_ways - 2) * 9 * pow(4, 2 * n - 2 - n - 2))
print(int(ans))