#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, k;
  cin >> n;
  ;
  for (i = 1; i <= n; i++) {
    if (i * i <= n && (i + 1) * (i + 1) > n) {
      break;
    }
  }
  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;
}
