#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wunused-result"
long long dp[100000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, j, n, t, temp = 0;
  vector<long long> a;
  i = 1;
  while (temp <= 1e6) {
    temp = i * i;
    a.push_back(temp);
    ++i;
  }
  cin >> n;
  long long val;
  for (i = 0; i < a.size(); i++) {
    if (a[i] == n) {
      cout << sqrt(n) * 4;
      return 0;
    }
    if (n < a[i]) {
      val = a[i - 1];
      break;
    }
  }
  j = n - val;
  if (j <= sqrt(val)) {
    cout << (sqrt(val) * 4) + 2;
  } else
    cout << (sqrt(val) * 4) + 4;
  return 0;
}
