#include <bits/stdc++.h>
using namespace std;
int nim[100000 + 5], useState[100000 + 5], precalcForNim[100000 + 5];
int main() {
  int n, b1;
  cin >> n;
  nim[1] = 0;
  for (int i = 2; i <= n; i++) {
    set<int> go;
    for (int k = 2; 2 * i - k * (k - 1) > 0; k++)
      if ((2 * i - k * (k - 1)) % (2 * k) == 0) {
        b1 = (2 * i - k * (k - 1)) / (2 * k);
        go.insert(precalcForNim[b1 + k - 1] ^ precalcForNim[b1 - 1]);
      }
    int m = 0;
    for (set<int>::const_iterator it = go.begin(); it != go.end(); m++, it++)
      if (*it != m) break;
    nim[i] = m;
    precalcForNim[i] = precalcForNim[i - 1] ^ m;
  }
  if (nim[n] == 0) {
    printf("-1");
  } else {
    int i = n;
    for (int k = 2; 2 * i - k * (k - 1) > 0; k++)
      if ((2 * i - k * (k - 1)) % (2 * k) == 0) {
        b1 = (2 * i - k * (k - 1)) / (2 * k);
        int x = 0;
        for (int j = b1; j < b1 + k; x ^= nim[j], j++)
          ;
        if (x == 0) {
          printf("%d", k);
          return 0;
        }
      }
  }
  return 0;
}
