#include <bits/stdc++.h>
using namespace std;
long long n;
bool f(long long q, long long w) {
  if (q * q <= w) return true;
  return false;
}
long long ridge(long long q) {
  long long r = q;
  long long l = 1;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    if (f(mid, q))
      l = mid;
    else
      r = mid;
  }
  return l;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  if (ridge(n) * ridge(n) == n) {
    cout << 4 * ridge(n);
    return 0;
  }
  if (n - ridge(n) * ridge(n) <= ridge(n)) {
    cout << 4 * ridge(n) + 2;
    return 0;
  }
  cout << 4 * ridge(n) + 4;
  return 0;
}
