#include <cstdio>
#include <assert.h>

const int MAXN = (int)1e9;

int main()
{
	freopen("beehive.in", "rt", stdin);
	freopen("beehive.out", "wt", stdout);
	long long n;
	scanf("%I64i", &n);
	assert(1 <= n && n <= MAXN);
	printf("%I64i", 3 * n * (n - 1) + 1);
	return 0;
}