#include <bits/stdc++.h>
const int MX = 1073741735;
const long long MXLL = 9223372036854775807;
const int Sz = 1110111;
using namespace std;
inline void rcin() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
long long sum, n;
int main() {
  rcin();
  cin >> n;
  if (n == 0) {
    cout << 1;
    return 0;
  }
  cout << 1 + ((n * (n + 1)) / 2) * 6;
  return 0;
}
