#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int closestSquare = (int)sqrt(static_cast<float>(n));
  float shortPath = (4 * closestSquare) +
                    ceil((n - pow(closestSquare, 2)) / closestSquare) * 2;
  cout << shortPath;
}
