#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
const long long inf = (1LL << 60 - 1);
int main() {
  long long n;
  cin >> n;
  n++;
  long long ans = 1;
  ans += n * (n - 1) / 2 * 6;
  cout << ans << endl;
  return 0;
}
