#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int number = 0;
  cin >> number;
  long long int answer = 1;
  for (int i = 2; i <= number; i++) answer = answer + 12 * (i - 1);
  cout << answer << endl;
  return 0;
}
