#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, result = 0;
  {
    cin >> n;
    float init = sqrt(n);
    if (init == floor(init))
      cout << init * 4 << endl;
    else {
      int init2 = floor(init);
      n = n - init2 * init2;
      result = init2 * 4;
      if (n > init2) {
        int temp1 = n / 2;
        result = result + (temp1 + 1) * 2 - temp1 * 2;
        int temp2 = n - n / 2;
        result = result + (temp2 + 1) * 2 - temp2 * 2;
      } else
        result = result + (n + 1) * 2 - n * 2;
      cout << result << endl;
    }
  }
  return 0;
}
