#include <bits/stdc++.h>
using namespace std;
long per(long i, long j) { return 2 * (i + j); }
int main() {
  long n, p, q;
  cin >> n;
  if ((long)sqrt(n) * (long)sqrt(n) == n) {
    cout << sqrt(n) * 4 << endl;
  } else {
    p = (long)sqrt(n) + 1;
    q = 1;
    while ((q * p) < n) {
      q++;
    }
    cout << per(p, q) << endl;
  }
  return 0;
}
