#include <bits/stdc++.h>
using namespace std;
int g[111111];
int w[111111];
set<int> s;
int main() {
  int n;
  int best = -1;
  cin >> n;
  g[1] = 0;
  g[2] = 0;
  for (int i = 3; i <= n; i++) {
    s.clear();
    for (int k = 2;; k++) {
      int x = (2 * i / k - k + 1) / 2;
      if (x < 1) break;
      if ((2 * x + k - 1) * k == 2 * i) {
        int val = w[x - 1] ^ w[x + k - 1];
        if (val == 0 && i == n && best == -1) best = k;
        s.insert(val);
      }
    }
    int res = 0;
    while (s.count(res)) res++;
    g[i] = res;
    w[i] = w[i - 1] ^ g[i];
  }
  cout << best << endl;
}
