#include <bits/stdc++.h>
using namespace std;
long long mod(long long x) {
  return ((x % 1000000009 + 1000000009) % 1000000009);
}
long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long mult(long long a, long long b) { return mod(mod(a) * mod(b)); }
long long modPow(long long a, long long b) {
  if (b == 0) return 1LL;
  if (b == 1) return a % 1000000009;
  long long res = 1;
  while (b) {
    if (b % 2 == 1) res = mult(res, a);
    a = mult(a, a);
    b = b / 2;
  }
  return res;
}
vector<long long> v(1000000);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  v[1] = 1;
  long long count = 1;
  for (long long i = 2; i <= n; i++) {
    v[i] = v[i - 1] + 6 + 6 * count;
    count += 2;
  }
  cout << v[n] << "\n";
  return 0;
}
