#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int maxn = 1000000 + 10;
int main() {
  int n;
  cin >> n;
  long long int s = 1;
  for (int i = 1; i < n; i++) s += i * 12;
  cout << s << endl;
}
