#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long n;
  cin >> n;
  long r = sqrt(n);
  long h = r;
  r = pow(r, 2);
  long y = sqrt(n) + 1;
  long p = y;
  y = pow(y, 2);
  long sum = 0;
  if (n - r < y - n) {
    sum += h * 4;
    long t = n - r;
    for (long i = 0; i < t; ++i) {
      if (i == 0) sum += 2;
    }
  } else {
    sum += p * 4;
  }
  cout << sum;
}
