#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int res = 0, fs = 1;
  char c = getchar();
  while (!(c >= '0' && c <= '9')) {
    if (c == '-') fs = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res * fs;
}
long long n, ans;
int main() {
  n = read();
  ans = 3 * n * n + 3 * n + 1;
  cout << ans << '\n';
  return 0;
}
