#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
void solve() {
  long long int n;
  cin >> n;
  long long int k = sqrt(n);
  long long int sum = 0;
  if (n == k * k) {
    cout << 4 * k << "\n";
    return;
  }
  sum = sum + k * 4;
  n = n - (k * k);
  if (n > (k)) {
    sum = sum + (n / (k)) * 2;
    if (n % k != 0) sum = sum + 2;
  } else {
    sum = sum + 2;
  }
  cout << sum << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
