#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  cin >> n;
  if (sqrt(n) == int(sqrt(n))) {
    cout << 4 * sqrt(n) << endl;
    return 0;
  }
  int tmp = sqrt(n);
  if (n < tmp * (tmp + 1))
    cout << 4 * tmp + 2 << endl;
  else if (n > tmp * (tmp + 1))
    cout << 2 * tmp + 2 * (tmp + 1) + 2 << endl;
  else
    cout << 2 * tmp + 2 * (tmp + 1) << endl;
  return 0;
}
