#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  double m;
  cin >> n;
  m = n;
  m = m / 2 + 0.5;
  n = n * m;
  cout << n * 6 + 1;
  return 0;
}
