#include <bits/stdc++.h>
const long long inf = 1000000000;
const long long inf64 = inf * inf;
const double pi = acos(-1.0);
long long Abs(long long x) { return (x >= 0 ? x : -x); }
using namespace std;
bool solve() {
  long long a;
  cin >> a;
  vector<long long> dp(a + 2);
  dp[1] = 1;
  dp[2] = 13;
  for (int i(3); i <= a; i++)
    dp[i] = (2 * i - 1) * 3 + (2 * (i - 1) - 1) * 3 + dp[i - 1];
  cout << dp[a] << '\n';
  return true;
}
int main() {
  solve();
  return 0;
}
