#include <bits/stdc++.h>
using namespace std;
int sg[100005];
int get(int n) {
  if (sg[n] != -1) return sg[n];
  int bo[1000] = {0};
  int k = 2, i;
  while (1) {
    if (k >= n) break;
    if ((2 * n - k * k + k) % (2 * k) != 0) {
      k++;
      continue;
    }
    int a1 = (2 * n - k * k + k) / (2 * k);
    if (a1 <= 0) break;
    int s = 0, i;
    for (i = a1; i < a1 + k; i++) {
      s ^= get(i);
    }
    bo[s] = 1;
    k++;
  }
  for (i = 0; bo[i]; i++)
    ;
  return sg[n] = i;
}
int get2(int n) {
  int bo[1000] = {0};
  int k = 2, i;
  memset(sg, -1, sizeof(sg));
  while (1) {
    if ((2 * n - k * k + k) % (2 * k) != 0) {
      k++;
      continue;
    }
    int a1 = (2 * n - k * k + k) / (2 * k);
    if (a1 <= 0) return -1;
    int s = 0, i;
    for (i = a1; i < a1 + k; i++) {
      s ^= get(i);
    }
    bo[s] = 1;
    if (s == 0) return k;
    k++;
  }
}
int main() {
  int n, i;
  cin >> n;
  cout << get2(n) << endl;
  return 0;
}
