#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, diff, difc, d;
  float sq;
  cin >> n;
  sq = sqrt(n);
  diff = n - floor(sq) * floor(sq);
  difc = ceil(sq) * ceil(sq) - n;
  d = min(diff, difc);
  if (d == 0)
    cout << 4 * (sq);
  else {
    if (diff <= difc)
      cout << 4 * floor(sq) + 2;
    else
      cout << 4 * ceil(sq);
  }
  return 0;
}
