#include <bits/stdc++.h>
using namespace std;
int dr[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
const int MAX = 1e6 + 7;
const int MOD = 1e9 + 7;
int main() {
  long long ans = 1, n;
  cin >> n;
  ans += n * (n + 1) * 3;
  cout << ans << "\n";
}
