56
 1
 46
 63478
 7578
 56056
 78
 66873
 8149
 35708
 81207
 41385
 37317
 74424
 67817
 684
 15
 96992
 38798
 19715
 627
 39509
 45899
 31893
 1515
 33
 95298
 27443
 60879
 99
 34378
 57113
 36655
 63359
 873
 67341
 100000
 42863
 35
 250
 573
 23
 871
 15748
 92763
 9564
 42602
 38
 42237
 70878
 93764
 303

-1
 -1
 4
 -1
 3
 -1
 4
 2
 2
 -1
 6
 15
 -1
 21
 73
 -1
 2
 -1
 76
 -1
 2
 -1
 -1
 3
 2
 2
 4
 2
 2
 2
 -1
 2
 -1
 34
 18
 2
 -1
 -1
 -1
 5
 3
 -1
 -1
 8
 22
 3
 17
 -1
 18
 -1
 -1
 2

#include <bits/stdc++.h>
using namespace std;
int memo[100020];
int grundy(int n) {
  if (memo[n] >= 0) return memo[n];
  set<int> st;
  for (int x = 2; x * x <= 2 * n; ++x)
    if ((2 * n) % x == 0) {
      int y = 2 * n / x;
      int b = (x + y - 1) / 2;
      int a = y - b;
      if (b - a + 1 != x || a + b != y || b - a + 1 < 2) continue;
      int g = 0;
      for (int c = (a); c <= (int)(b); ++c) g ^= grundy(c);
      st.insert(g);
    }
  int g = 0;
  while (st.count(g)) g++;
  return memo[n] = g;
}
int main() {
  int N;
  memset((memo), (-1), sizeof(memo));
  for (int i = (1); i <= (int)(100000); ++i) grundy(i);
  while (cin >> N) {
    if (grundy(N) == 0)
      puts("-1");
    else {
      int k = 1 << 29;
      for (int x = 2; x * x <= 2 * N; ++x)
        if ((2 * N) % x == 0) {
          int y = 2 * N / x;
          int b = (x + y - 1) / 2;
          int a = y - b;
          if (b - a + 1 != x || a + b != y || b - a + 1 < 2) continue;
          int g = 0;
          for (int c = (a); c <= (int)(b); ++c) g ^= grundy(c);
          if (g == 0) k = min(k, b - a + 1);
        }
      printf("%d\n", k);
    }
  }
}
