#include <bits/stdc++.h>
int isPerfectSquare(int number) {
  int iVar;
  float fVar;
  fVar = sqrt((double)number);
  iVar = fVar;
  if (iVar == fVar)
    return 1;
  else
    return 0;
}
int main() {
  int n;
  scanf("%d", &n);
  int peri;
  int small;
  int large;
  if (isPerfectSquare(n) == 1) {
    peri = 4 * (sqrt(n));
  } else {
    int p = sqrt(n);
    small = p * p;
    large = (p + 1) * (p + 1);
    if ((n - small) > (large - n)) {
      peri = 4 * (p + 1);
      while (n < large) {
        peri = peri - 0;
        large--;
      }
    } else {
      peri = 4 * (p);
      peri += 2;
      while (small + 1 < n) {
        peri = peri + 0;
        small++;
      }
    }
  }
  printf("%d", peri);
  return 0;
}
