#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, p, q, r, c, s, x, y;
  cin >> n;
  k = sqrt(n);
  p = k * k;
  q = n - p;
  r = q / k;
  c = (k + r);
  s = n - k * c;
  if (s > 0) {
    cout << 2 * (k + c) + 2 << endl;
    ;
  } else
    cout << 2 * (k + c) << endl;
}
