#include <bits/stdc++.h>
using namespace std;
double x;
int n, m;
int main() {
  cin >> x;
  n = sqrt(x);
  m = (n + (n != sqrt(x)));
  while (n * m < x) {
    if (n > m) {
      swap(n, m);
    }
    n++;
  }
  cout << ((n - 2) * 2) + ((m - 2) * 2) + 8 << endl;
  return 0;
}
