#include <bits/stdc++.h>
using namespace std;
long long int n, i, l2, l4, j, k, l, ans[101];
int main() {
  cin >> n;
  for (i = 0; i <= 100; i++) ans[i] = -1;
  for (i = 101; i > 0;) {
    if ((i / 2) % 2) {
      l2 = (((i + 1) / 2) / 2 - 1) * 2;
      l4 = ((i + 1) / 2) * (((i + 1) / 2) / 2) - l2 - 1;
      for (j = 0; j <= l2; j++) {
        for (k = 0; k <= l4; k++) {
          l = 1 + 2 * j + 4 * k;
          if (l > 100) break;
          ans[l] = i;
        }
      }
      l2 = (((i + 1) / 2) / 2) * 2;
      l4 = ((i + 1) / 2) * (((i + 1) / 2) / 2) - l2;
      for (j = 0; j <= l2; j++) {
        for (k = 0; k <= l4; k++) {
          l = 2 * j + 4 * k;
          if (l > 100) break;
          ans[l] = i;
        }
      }
    } else {
      l2 = i / 2;
      l4 = ((i / 2) / 2) * l2;
      for (j = 0; j <= l2; j++) {
        for (k = 0; k <= l4; k++) {
          l = 1 + 2 * j + 4 * k;
          if (l > 100) break;
          ans[l] = i;
        }
      }
      l2 = i / 2;
      l4 = ((i / 2) / 2) * l2;
      for (j = 0; j <= l2; j++) {
        for (k = 0; k <= l4; k++) {
          l = 2 * j + 4 * k;
          if (l > 100) break;
          ans[l] = i;
        }
      }
    }
    i -= 2;
  }
  cout << ans[n];
  return 0;
}
