#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  long long ans = 1ll << 60;
  for (int i = 1; 1ll * i * i <= n; i++) {
    int j = (n + i - 1) / i;
    ans = min(ans, 2ll * (j + i));
  }
  cout << ans;
  return 0;
}
