#include <bits/stdc++.h>
using namespace std;
const int maxN = 100 * 1000 + 100;
int n, w[maxN], SHIT[maxN], best[maxN];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  w[1] = 0;
  for (int i = 2; i <= n; i++) {
    set<int> g;
    for (int k = 2; k * (k + 1) / 2 <= i; k++) {
      int r = i - k * (k + 1) / 2;
      if (r % k == 0) {
        int x = r / k + 1, y = r / k + k;
        int s = SHIT[y] ^ SHIT[x - 1];
        g.insert(s);
        if (s == 0 && best[i] == 0) {
          best[i] = k;
        }
      }
    }
    while (g.find(w[i]) != g.end()) w[i]++;
    SHIT[i] = SHIT[i - 1] ^ w[i];
  }
  if (w[n] == 0)
    cout << -1 << endl;
  else
    cout << best[n] << endl;
  cin >> n;
  return 0;
}
