#include <bits/stdc++.h>
using namespace std;
void pairsort(long long a[], long long b[], long long k) {
  pair<long long, long long> pairt[k];
  for (long long i = 0; i < k; i++) {
    pairt[i].first = a[i];
    pairt[i].second = b[i];
  }
  sort(pairt, pairt + k);
  for (long long i = 0; i < k; i++) {
    a[i] = pairt[i].first;
    b[i] = pairt[i].second;
  }
}
long long CheckPrime(long long k) {
  for (long long i = 2; i < k; i++)
    if (k % i == 0) return 0;
  return 1;
}
long long countdigit(long long n) { return floor(log10(n) + 1); }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long ans = 1 + 3 * n * (n + 1);
  cout << ans;
}
