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