#include <bits/stdc++.h>
using namespace std;
long long n, lat, dif, sol;
int main() {
  cin >> n;
  lat = 1;
  while (lat * lat <= n) {
    lat++;
  }
  lat--;
  dif = n - lat * lat;
  if (dif == 0) {
    sol = lat * 4;
  } else if (dif <= lat) {
    sol = lat * 4 + 2;
  } else {
    if (dif > lat) {
      sol = lat * 4 + 2 * 2;
    }
  }
  cout << sol;
  return 0;
}
