#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int p, sq, diff;
  p = sqrt(n);
  sq = p * p;
  int ans = 4 * p;
  diff = n - sq;
  if (diff == 0) {
    cout << ans;
    return 0;
  }
  if (diff <= p)
    ans += 2;
  else
    ans += 4;
  cout << ans;
  return 0;
}
