<image>

Input

The input contains a single integer a (1 ≤ a ≤ 18257).

Output

Print a single integer output (1 ≤ output ≤ 2·109).

Examples

Input

2


Output

13
def hex(n):
    return 3 * n * (n+1) + 1
def tri(n):
    return n * (n+1) / 2

import sys
n = int(sys.stdin.readline())
print 2 * tri(3 * n - 2) - hex(n - 1)
