#include <bits/stdc++.h>
using namespace std;
int ara[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t, n, total = 0;
  cin >> n;
  total = 3 * n * (n + 1) + 1;
  cout << total << endl;
  return 0;
}
