#include <bits/stdc++.h>
using namespace std;
int main() {
  long double n;
  cin >> n;
  long double y = (n - 1) / 2;
  y = n * y;
  long double x = 6 * (n * n - y);
  long long t = x;
  cout << fixed << t + 1 << endl;
  return 0;
}
