#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int NMAX = 100000;
int T[NMAX + 1], best[NMAX + 1];
int mex(const vector<int>& A) {
  int res = 0;
  for (int i = 0, _n = (A.size()); i < _n; ++i) {
    if (A[i] > res) return res;
    if (A[i] == res) ++res;
  }
  return res;
}
int main() {
  for (int pos = (1), _n = (NMAX); pos <= _n; ++pos) {
    best[pos] = -1;
    vector<int> moves;
    for (int k = 2; true; ++k) {
      if ((k + 1) * k / 2 > pos) break;
      int tmp = pos;
      tmp -= (k + 1) * k / 2;
      if (tmp % k != 0) continue;
      tmp /= k;
      int val = 0;
      for (int i = (1), _n = (k); i <= _n; ++i) val ^= T[tmp + i];
      if (val == 0 && best[pos] == -1) best[pos] = k;
      moves.push_back(val);
    }
    sort((moves).begin(), (moves).end());
    T[pos] = mex(moves);
  }
  int n;
  scanf("%d", &n);
  printf("%d\n", best[n]);
}
