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