#include <bits/stdc++.h>
using namespace std;
int main() {
  int long long ans = 1;
  int long long part = 1;
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    part = part + 2;
    ans += part * 6 - 6;
  }
  cout << ans << endl;
  return 0;
}
