#include <bits/stdc++.h>
using namespace std;
int main() {
  double x1, x2;
  while (~scanf("%lf", &x1)) {
    x2 = x1;
    double n, a;
    for (x1;; x1++) {
      n = sqrt(x1);
      a = (int)n;
      if (a == n) break;
    }
    int z = n;
    int num = (int)x1 - x2;
    int count = 0;
    if (num >= z) {
      count++;
      if (num - z >= z - 1) count++;
    }
    printf("%d\n", z * 4 - count * 2);
  }
}
