#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int r = 1;
    for (int i = 0, j = 0; i < n; i++, j += 2) r += j * 6;
    cout << r << endl;
  }
  return 0;
}
