#include <bits/stdc++.h>
using namespace std;
long long int ok = 1000 * 1000 * 1000 + 7;
vector<pair<long long int, long long int> > v;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  cout << n * (3 + n * 3) + 1;
}
