#include <bits/stdc++.h>
int n, x, y;
int main() {
  scanf("%d", &n);
  x = 1;
  y = 1;
  while (x * y <= n) {
    if (x * x <= n) y = x;
    if (x * (x + 1) <= n) y = x + 1;
    ++x;
  }
  --x;
  if (n - (x * y) > 0)
    printf("%d", 2 * x + 2 * y + 2);
  else
    printf("%d", 2 * x + 2 * y);
  return 0;
}
