#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sq, ans;
  cin >> n;
  sq = (int)sqrt(n);
  ans = sq * 4;
  n -= sq * sq;
  if (n > 0) {
    ans += (n / sq) * 2;
    if (n % sq != 0) ans += 2;
  }
  cout << ans << endl;
  return 0;
}
