#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a;
  if (a == 1) {
    cout << '1';
    return 0;
  }
  if (a == 2) {
    cout << "13";
    return 0;
  }
  long long sol = 1;
  sol += 1LL * 6 * a * (a + 1) / 2;
  sol += 1LL * 6 * ((a - 2) * (a - 1) / 2 - 1);
  cout << sol << '\n';
  return 0;
}
