#include <bits/stdc++.h>
using namespace std;
int a[200000];
int main() {
  int n, m, i;
  a[1] = 1;
  for (i = 2; i <= 18257; i++) a[i] = a[i - 1] + 12 * (i - 1);
  while (~scanf("%d", &n)) {
    printf("%d\n", a[n]);
  }
  return 0;
}
