#include <bits/stdc++.h>
using namespace std;
int sg[100100] = {0, 0, 0};
int sgs[100100] = {0, 0, 0};
bool mark[2020];
int solve(int n) {
  memset(mark, false, sizeof(mark));
  for (int i = 2; (1 + i) * i / 2 <= n; i++) {
    if ((n - (1 + i) * i / 2) % i != 0) continue;
    int k = (n - (1 + i) * i / 2) / i;
    int t = sgs[k] ^ sgs[k + i];
    mark[t] = true;
  }
  for (int i = 0; i <= n; i++)
    if (!mark[i]) return i;
}
int main() {
  for (int i = 3; i <= 100000; i++) {
    sg[i] = solve(i);
    sgs[i] = sgs[i - 1] ^ sg[i];
  }
  int N;
  while (~scanf("%d", &N)) {
    bool flag = false;
    int res;
    for (int i = 2; (1 + i) * i / 2 <= N; i++) {
      if ((N - (1 + i) * i / 2) % i != 0) continue;
      int k = (N - (1 + i) * i / 2) / i;
      int t = 0;
      for (int j = 1; j <= i; j++) {
        t ^= sg[j + k];
      }
      if (t == 0) {
        flag = true;
        res = i;
        break;
      }
    }
    if (flag)
      printf("%d\n", res);
    else
      printf("-1\n");
  }
  return 0;
}
