#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[18530];
  arr[0] = 0;
  arr[1] = 1;
  arr[2] = 13;
  for (int i = 3; i <= 18527; i++) arr[i] = 12 * (i - 1) + arr[i - 1];
  int n;
  cin >> n;
  cout << arr[n] << endl;
}
