#include <bits/stdc++.h>
using namespace std;
long long n, i, m, k, l, r, d, ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  l = 1;
  r = n;
  while (l <= r) {
    d = (l + r) / 2;
    if (d * d >= n) {
      m = d;
      r = d - 1;
    } else
      l = d + 1;
  }
  k = (n + m - 1) / m;
  n = m * k;
  ans = m * 4 - ((m * m - n) / m * 2);
  cout << ans << '\n';
  return 0;
}
