#include <bits/stdc++.h>
using namespace std;
int fen[100100];
int n, ans = -1, a[100100];
int calc(int ind) {
  int ans = 0;
  for (int i = ind; i >= 1; i -= i & (-i)) ans ^= fen[i];
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(fen, 0, sizeof(fen));
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int t;
    int p = 0;
    set<int> s;
    for (int j = 2; j * (j + 1) / 2 <= i; j++) {
      int k = i - j * (j + 1) / 2;
      if (k % j != 0) continue;
      k /= j;
      t = calc(k + j) ^ calc(k);
      if (i == n and ans == -1 and !t) ans = j;
      s.insert(t);
    }
    while (s.count(p)) p++;
    for (int j = i; j <= n; j += j & (-j)) fen[j] ^= p;
  }
  cout << ans;
  return 0;
}
