#include <bits/stdc++.h>
using namespace std;
long star(int a) {
  if (a == 1)
    return 1;
  else
    return star(a - 1) + 12 * (a - 1);
}
int main() {
  int n;
  cin >> n;
  cout << star(n) << endl;
}
