#include <bits/stdc++.h>
int main(void) {
  long long N, x, y, sum;
  scanf("%lld", &N);
  x = sqrt(N);
  y = N - x * x;
  if (y == 0) {
    sum = 4 * x;
  } else if (y > 0 && y <= x) {
    sum = 4 * x + 2;
  } else {
    sum = 4 * x + 4;
  }
  printf("%lld", sum);
  return 0;
}
