#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, i, x, maxi = 1, ans, chk, tmp;
  scanf("%d", &k);
  for (i = 1; i * i <= k; i++) maxi = i;
  if (maxi == 1) {
    if (k == 1)
      ans = 4;
    else if (k == 2)
      ans = 6;
    else if (k == 3)
      ans = 8;
  } else if (k == (maxi * maxi))
    ans = maxi * 4;
  else {
    ans = maxi * 2;
    ans += (k / maxi);
    tmp = k % maxi;
    chk = (k / maxi) - tmp;
    if (tmp == 0)
      ans += chk + tmp;
    else
      ans += chk + tmp + 2;
  }
  printf("%d\n", ans);
  return 0;
}
