#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
vector<int> G[100009];
int main() {
  unsigned long long int n;
  cin >> n;
  unsigned long long int ans = (n * (2 * 6 + (n - 1) * 6)) / 2;
  cout << ans + 1 << endl;
  return 0;
}
