#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:260108864")
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int res(1);
  int temp(1);
  while (--n) {
    res += temp * 12;
    ++temp;
  }
  printf("%d\n", res);
  return 0;
}
