#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  scanf("%d", &n);
  vector<int> game(n + 1);
  game[0] = game[1] = game[2] = 0;
  vector<int> res(n + 1, -1);
  for (int i = 3; i <= n; i++) {
    int ok[300001];
    memset(ok, 0, sizeof(0));
    for (int j = 2; i - (j * (j - 1)) / 2 >= 0; j++) {
      int x = i - ((j) * (j - 1)) / 2;
      if (x % j == 0) {
        x /= j;
        int Xor = 0;
        for (int k = 0; k < j; k++) {
          Xor ^= game[x + k];
        }
        ok[Xor] = i;
        if (Xor == 0 && res[i] == -1) {
          res[i] = j;
        }
      }
    }
    int r = 0;
    while (ok[r] == i) r++;
    game[i] = r;
    if (game[i] == 0) res[i] = -1;
  }
  printf("%d\n", res[n]);
}
