#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, ans = 1, k;
  cin >> n;
  ans = 3 * n - 2;
  ans = (ans * (ans + 1)) / 2;
  k = 3 * (n * (n - 1)) / 2;
  cout << k + ans;
}
