#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265359;
int main() {
  vector<int> v;
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  unsigned long long n, j = 0, i = 0, b, f = 1, x = 0, t = 0, g = 0, r, k, qr,
                        qc, z = 100, c[10000], a;
  string ch, s[100], asd;
  cin >> n;
  n = 6 * n * (n + 1) / 2 + 1;
  cout << n;
  return 0;
}
