#include <bits/stdc++.h>
using namespace std;
int s[18257 + 1];
int main() {
  memset(s, 0, sizeof(s));
  s[1] = 1;
  for (int i = 2; i <= 18257; i++) {
    s[i] = (2 * i - 3) * 6 + 6;
  }
  int a;
  scanf("%d", &a);
  if (a == 1) {
    cout << s[1] << endl;
  } else {
    int sum = 0;
    for (int i = 1; i <= a; i++) {
      sum += s[i];
    }
    cout << sum << endl;
  }
  return 0;
}
