#include <bits/stdc++.h>
using namespace std;
int n, a[50], ans = 0;
bool joined[1000001];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  int e = sqrt(n);
  int miss = n - e * e;
  if (e * e == n)
    cout << 4 * e;
  else if (miss && miss <= e)
    cout << 4 * e + 2;
  else
    cout << 4 * (e + 1);
}
