#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int a;
int main() {
  cin >> a;
  int ans = 1;
  for (int i = 2; i <= a; i++) {
    ans += (2 * i - 2) * 6;
  }
  cout << ans << endl;
  return 0;
}
