#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  while (scanf("%d", &a) != EOF) {
    long long ans(1), dx(3);
    for (int i = 2; i <= a; ++i) {
      ans += 6 * dx - 6;
      dx += 2;
    }
    printf("%I64d\n", ans);
  }
}
