#include <bits/stdc++.h>
using namespace std;
const int N = 2000006;
const unsigned long long hs = 5123;
vector<int> prime[N];
long long in[N], n, x, y, res = 0;
int main() {
  long long n;
  cin >> n;
  long long m = sqrt(n);
  long long rem = n - m * m;
  long long ans = m * 4;
  if (rem && rem <= m)
    ans += 2;
  else if (rem)
    ans += 4;
  cout << ans << '\n';
}
