#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, res = 1, s = 0;
  cin >> a;
  for (int i = 1; i < a; i++) {
    s += 12;
    res += s;
  }
  cout << res;
  return 0;
}
