#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10, SQ = 350;
int n, gr[MAXN], p[MAXN], win[MAXN], mark[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 2; j <= SQ; j++) {
      int x = 2 * i;
      if (x % j) continue;
      x /= j;
      x -= j - 1;
      if (x <= 0 || x % 2) continue;
      x /= 2;
      mark[(p[x + j] ^ p[x])] = i;
      if ((p[x + j] ^ p[x]) == 0)
        if (!win[i]) win[i] = j;
    }
    while (mark[gr[i]] == i) gr[i]++;
    p[i + 1] = p[i] ^ gr[i];
  }
  if (win[n])
    cout << win[n] << endl;
  else
    cout << -1 << endl;
  return 0;
}
