#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
const long M = 1000000007;
long long int c(long long int n, long long int k) {
  long long int C[k + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = min(i, k); j > 0; j--) C[j] = C[j] + C[j - 1];
  }
  return C[k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int n;
  cin >> n;
  cout << 3 * n * (n + 1) + 1 << "\n";
  return 0;
}
