#include <bits/stdc++.h>
using namespace std;
const int nmax = 20;
const int inf = 1e9 + 7;
const int modulo = 1e9 + 7;
const double linf = 1e36;
int main() {
  long long n;
  scanf("%I64d", &n);
  long long ret = 3 * n * (n + 1) + 1;
  printf("%I64d\n", ret);
  return 0;
}
