#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
  for (Tp current = _begin; current != _end; ++current) {
    std::cout << *current << _delim;
  }
  std::cout << '\n';
}
using ll = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
int F(int x) {
  if (x == 1) {
    return 1;
  }
  return 12 * (x - 1);
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a;
  cin >> a;
  ll ans = 0;
  for (int i = 1; i <= a; ++i) {
    ans += F(i);
  }
  cout << ans << "\n";
  return 0;
}
