#include <bits/stdc++.h>
using namespace std;
int triangle(long long n) {
  if (n == 1)
    return 1;
  else
    return n + triangle(n - 1);
}
int heart(long long a) {
  if (a == 1)
    return 1;
  else
    return (6 * (a - 1)) + heart(a - 1);
}
int balls(long long a) {
  if (a == 1)
    return 1;
  else
    return heart(a) + (triangle(a - 1) * 6);
}
int main() {
  long long a, b;
  cin >> a;
  b = balls(a);
  cout << b;
  return 0;
}
