#include <bits/stdc++.h>
using namespace std;
int n;
int v[101000];
int Ans[101000];
int sg[101000];
int SG(int n) {
  for (int i = 2; i <= n; i++) {
    int temp;
    if (i & 1) {
      if (i / 2 >= n / i) break;
      if (n % i) continue;
      temp = sg[n / i + i / 2] ^ sg[n / i - i / 2 - 1];
    } else {
      if (i / 2 > n / i) break;
      if (n * 2 % i) continue;
      if (n * 2 / i % 2 == 0) continue;
      temp = sg[n / i + i / 2] ^ sg[n / i - i / 2];
    }
    if (!temp && Ans[n] == -1) Ans[n] = i;
    v[temp] = n;
  }
  for (int i = 0; i <= n; i++)
    if (v[i] != n) return i;
}
int main() {
  scanf("%d", &n);
  sg[0] = sg[1] = sg[2] = 0;
  memset(Ans, -1, sizeof Ans);
  for (int i = 3; i <= n; i++) {
    int temp = SG(i);
    sg[i] = sg[i - 1] ^ temp;
  }
  printf("%d\n", Ans[n]);
  return 0;
}
