#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, k;
  cin >> n;
  ;
  i = sqrt(n);
  k = n - i * i;
  if (i * i == n)
    cout << 4 * (i) << endl;
  else if (k - i <= 0)
    cout << 4 * i + 2 << endl;
  else
    cout << 4 * i + 4 << endl;
}
