#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  scanf("%d", &n);
  int x = int(sqrt(n));
  if (x * x == n)
    printf("%d\n", 4 * x);
  else if (n - x * x <= x)
    printf("%d\n", 4 * x + 2);
  else
    printf("%d\n", 4 * x + 4);
  return 0;
}
