#include <bits/stdc++.h>
int in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
int main() {
  int N = in();
  long long res = 1;
  for (int i = 2; i <= N; i++) {
    res = res + ((i * 2 - 1) * 6) - 6;
    if (res > 2000000000) {
      res = 2000000000;
      break;
    }
  }
  printf("%d\n", res);
}
