#include <bits/stdc++.h>
int n, f[100010], g[100010], b[30];
int main() {
  scanf("%d", &n);
  f[1] = 0;
  f[2] = 0;
  for (int i = 3; i <= n; i++) {
    memset(b, 0, sizeof b);
    for (int j = 2; j <= trunc(sqrt(2 * i)); j++)
      if ((2 * i - (j * j - j)) % (2 * j) == 0) {
        int k = (2 * i - (j * j - j)) / (2 * j);
        int l = g[k - 1] xor g[k + j - 1];
        b[l] = 1;
      }
    for (int j = 0; j <= 30; j++)
      if (b[j] == 0) {
        f[i] = j;
        break;
      }
    g[i] = g[i - 1] xor f[i];
  }
  int ans = 0;
  for (int j = 2; j <= trunc(sqrt(2 * n)); j++)
    if ((2 * n - (j * j - j)) % (2 * j) == 0) {
      int k = (2 * n - (j * j - j)) / (2 * j);
      int l = g[k - 1] xor g[k + j - 1];
      if (l == 0) {
        ans = j;
        break;
      }
    }
  if (f[n] == 0)
    printf("-1");
  else
    printf("%d", ans);
  return 0;
}
