MOD = 10**9+7 N = int(input()) if N==1: print(12) else: print((3*N*2+1)**2//2+1)