#include <bits/stdc++.h>
template <typename T>
T inline SQR(const T &a) {
  return a * a;
}
template <typename T>
T inline ABS(const T &a) {
  return a < 0 ? -a : a;
}
const double EPS = 1e-9;
inline int SGN(double a) {
  return ((a > EPS) ? (1) : ((a < -EPS) ? (-1) : (0)));
}
inline int CMP(double a, double b) { return SGN(a - b); }
using namespace std;
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  cout << (6LL * n * n - 6LL * n + 1LL) << "\n";
  return 0;
}
