#include <bits/stdc++.h>
using namespace std;
int ini() {
  int a;
  scanf("%d", &a);
  return a;
}
long long inl() {
  long long a;
  scanf("%lld", &a);
  return a;
}
char inc() {
  char a;
  scanf("%c", &a);
  return a;
}
const int maxn = 111222;
int n, f[maxn], s[maxn], g[maxn << 1], res = 111222;
int main() {
  if (0) {
    freopen("aaa.inp", "r", stdin);
    freopen("aaa.out", "w", stdout);
  };
  n = ini();
  for (int i = 1; i <= n; i++) {
    for (int j = 2;; j++) {
      int c = i - j * (j + 1) / 2;
      if (c < 0) break;
      if (c % j == 0) {
        c /= j;
        g[s[c + j] ^ s[c]] = i;
        if ((s[c + j] ^ s[c]) == 0 && i == n) {
          cout << j;
          return 0;
        }
      }
    }
    for (int j = 0;; j++)
      if (g[j] < i) {
        f[i] = j;
        break;
      }
    s[i] = s[i - 1] ^ f[i];
  }
  cout << -1;
  return 0;
};
