#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  int t = 13;
  int n;
  cin >> n;
  if (n == 1)
    cout << 1;
  else {
    int k = 24;
    for (int i = 0; i < (n - 2); i++) {
      t += k;
      k += 12;
    }
    cout << t;
  }
  return 0;
}
