#include <bits/stdc++.h>
using namespace std;
long long shar(long long a) {
  long long ans = (a + 1) * a / 2;
  return ans;
}
int main() {
  long long a;
  cin >> a;
  long long h = shar(3 * a - 2) + 3 * shar(a - 1);
  cout << h;
  return 0;
}
