#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 6;
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  long long temp = 1 + (n - 1) * 3;
  cout << (temp * (temp + 1)) / 2 + 3 * ((n - 1) * n) / 2;
  return 0;
}
