#include <bits/stdc++.h>
using namespace std;
int a, res, i, side, cnt;
int main() {
  cin >> a;
  cnt = 0;
  if (a == 1)
    res = 1;
  else {
    res = 1;
    side = 1;
    for (i = 1; i < a; i++) {
      side += 3;
      res += side * 3;
      if (i > 1) res += cnt * 3;
      cnt++;
    }
  }
  cout << res << endl;
  return 0;
}
