#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  long long n;
  cin >> n;
  cout << ((long long)6 * n * (n + (long long)1) / (long long)2) + (long long)1;
  return 0;
}
