#include <bits/stdc++.h>
using namespace std;
long long n, t, i, j, k, l, low, mid, high, dp[100000];
string yes = "Yes";
string no = "No";
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int modulo(long double a, long double b) {
  long double x;
  if (b == 0) return 1;
  x = modulo(a, b / 2);
  if (b / 2 != floor(b / 2))
    return (x * x);
  else
    return (a * (x * x));
}
void solve() {
  long long n;
  cin >> n;
  long long sum = 1 + 3 * (n) * (n + 1);
  cout << sum << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
