#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, x;
  double c;
  cin >> n;
  c = sqrt(n);
  x = sqrt(n);
  if (c > x && c > x + 0.5)
    cout << 2 * (2 * x + 2);
  else if (c > x && c < x + 0.5)
    cout << 2 * (2 * x + 1);
  else if (c == x)
    cout << x * 4;
  return 0;
}
