#include <bits/stdc++.h>
using namespace std;
int dp[100005], sg[100005], n;
bool chksqu(long long n) {
  long long r = (long long)sqrt(1.0 * n);
  if (r * r == n) return 1;
  if ((r - 1) * (r - 1) == n) return 1;
  if ((r + 1) * (r + 1) == n) return 1;
  return 0;
}
int saya(int n) {
  if (dp[n] != -1) return dp[n];
  dp[n] = 1 << 30;
  set<int> st;
  for (long long i = n / 2; i >= 1; i--) {
    if (chksqu(4 * i * i - 4 * i + 8 * n + 1)) {
      int tsg = 0, cntp = 0;
      for (int tn = n, j = i; tn; j++) {
        if (saya(j)) tsg ^= sg[j];
        cntp++;
        tn -= j;
      }
      if (tsg == 0) dp[n] = min(dp[n], cntp);
      st.insert(tsg);
    }
  }
  long long i;
  for (i = 0;; i++)
    if (st.find(i) == st.end()) break;
  sg[n] = i;
  if (sg[n] == 0) dp[n] = 0;
  return dp[n];
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  if (saya(n))
    printf("%d\n", saya(n));
  else
    puts("-1");
}
