#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long i = 1;
  int res;
  cin >> N;
  while (i * i <= N) i++;
  i--;
  if ((i * i) == N)
    res = 4 * i;
  else if ((N - i * i) > i)
    res = 4 * i + 4;
  else
    res = 4 * i + 2;
  cout << res;
  return 0;
}
