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