#include <bits/stdc++.h>
using namespace std;
void solve(void) {
  int N;
  long int s = 0;
  cin >> N;
  for (int i = 2; i <= N; i++) s += i - 1;
  cout << s * 6 * 2 + 1 << endl;
}
int main(int argc, char const *argv[]) {
  solve();
  return 0;
}
