#include <bits/stdc++.h>
const double eps = 1e-10;
using namespace std;
int dblcmp(double x) {
  if (fabs(x) < eps) return 0;
  return x > 0 ? 1 : -1;
}
int main() {
  int i, j, k, n;
  int a, b;
  string s;
  while (cin >> a) {
    k = 1;
    for (i = 1; i < a; ++i) k += 12 * i;
    cout << k << endl;
  }
  return 0;
}
