#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a, b, c;
  a = sqrt(n);
  b = (n - (a * a));
  c = b / a;
  int ans = 0, d, e;
  ans = a + c;
  d = b % a;
  if (d > 0)
    ans = 2 * (a + a + c) + 2;
  else
    ans = 2 * (a + a + c);
  cout << ans;
  return 0;
}
