#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int side = sqrt(n);
  int blocks = (side * side);
  if (blocks == n) {
    int ans = (4 * side);
    cout << ans << "\n";
  } else {
    side++;
    int ans = (4 * (side));
    blocks = (side * side);
    while (blocks > n) {
      blocks -= (side);
      ans -= (2);
    }
    if (blocks == n)
      cout << ans << "\n";
    else
      cout << ans + 2 << "\n";
  }
  return 0;
}
