#include <bits/stdc++.h>
using namespace std;
int n, a;
int sg[100010];
int choose;
int main() {
  while (scanf("%d", &n) != EOF) {
    memset(sg, 0, sizeof(sg));
    choose = 0;
    for (int num = 3; num <= n; num++) {
      set<int> mex;
      for (int k = 2; k * k < 2 * num; k++) {
        int left = num - k * (k - 1) / 2;
        if (left > 0 && left % k == 0 && left / k > 0) {
          a = left / k;
          mex.insert(sg[a + k - 1] ^ sg[a - 1]);
          if (num == n && (sg[a + k - 1] ^ sg[a - 1]) == 0 && !choose)
            choose = k;
        }
      }
      for (int i = 0;; i++)
        if (!mex.count(i)) {
          sg[num] = i;
          break;
        }
      sg[num] ^= sg[num - 1];
    }
    if ((sg[n] ^ sg[n - 1]) == 0)
      printf("-1\n");
    else
      printf("%d\n", choose);
  }
  return 0;
}
