#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  unsigned long long n;
  cin >> n;
  if (n == 0) {
    cout << 1 << "\n";
    return 0;
  }
  cout << 3 * n * (n + 1) + 1 << "\n";
}
