#include <bits/stdc++.h>
using namespace std;
bool prime(long long n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
void xd(bool i) {
  if (i)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
bool repeat(string s) {
  for (int i = 0; i < s.length() - 1; i++)
    if (s[i] == s[i + 1]) return false;
  return true;
}
void arrintf(int n, int a[]) {
  for (int i = 0; i < n; i++) cin >> a[i];
}
int main(int argc, char const *argv[]) {
  long long n;
  scanf("%lld", &n);
  printf("%lld\n", (2 * 6 + (n - 1) * 6) / 2 * n + 1);
  return 0;
}
