#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int s = 0;
  for (int i = 1; i <= n; i++) {
    int t = sqrt(i);
    if (t * t == i) s = i;
  }
  int r = n - s;
  int c = 4 * sqrt(s);
  int y;
  int z = sqrt(s);
  if (r % z == 0)
    y = r / sqrt(s);
  else
    y = r / sqrt(s) + 1;
  c += 2 * (y);
  cout << c;
}
