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