#include <bits/stdc++.h>
using namespace std;
int dp[100005];
int nn;
int ret;
int sg(int n) {
  if (dp[n] != -1 && n != nn) return dp[n];
  bool flag[100] = {0};
  memset(flag, 0, sizeof(flag));
  int m = n * 2, x, y, a, b, i, s;
  for (y = 2; y * y < m; ++y) {
    if (m % y == 0) {
      x = m / y;
      for (int t = 2; t--;) {
        swap(x, y);
        if ((x + y - 1) % 2 || (x - y + 1) % 2 || x < 3) continue;
        a = (x + y - 1) / 2;
        b = (x - y + 1) / 2;
        if (a - b < 1 || b <= 0) continue;
        s = 0;
        for (i = b; i <= a; ++i) {
          s ^= sg(i);
        }
        flag[s] = true;
        if (s == 0 && n == nn) {
          if (a - b < ret) ret = a - b;
          ;
        }
      }
    }
  }
  for (i = 0; flag[i] && i < 100; ++i)
    ;
  return dp[n] = i;
}
int main() {
  memset(dp, -1, sizeof(dp));
  dp[0] = dp[1] = dp[2] = 0;
  while (cin >> nn) {
    ret = 100000000;
    int t = sg(nn);
    if (t == 0) {
      puts("-1");
    } else {
      printf("%d\n", ret + 1);
    }
  }
  return 0;
}
