#include <bits/stdc++.h>
using namespace std;
int g[100001];
int main() {
  int n;
  scanf("%d", &n);
  int win_move = -1;
  for (int i = 2; i <= n; i++) {
    int k = 2;
    int m = i;
    set<int> grundy;
    while (1) {
      int minus = ((k - 1) * (k)) / 2;
      if (m < minus) break;
      if ((m - minus) % k == 0) {
        int ak = (m - minus) / k;
        int ans = 0;
        for (int j = 0; j < k; j++) {
          ans ^= g[ak + j];
        }
        grundy.insert(ans);
        if (ans == 0 and m == n and win_move == -1) win_move = k;
      }
      k++;
    }
    set<int>::iterator it = grundy.begin();
    int ans = 0;
    while (it != grundy.end() and *it == ans) {
      it++;
      ans++;
    }
    g[m] = ans;
  }
  printf("%d\n", win_move);
  return 0;
}
