#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> f(n + 1, 0);
  int odp = INF;
  for (int i = 1; i < n + 1; ++i) {
    vector<int> d;
    for (int j = 1; j * j <= 2 * i; ++j) {
      if ((2 * i) % j == 0) d.push_back(j);
      if ((2 * i) % ((2 * i) / j) == 0)
        if (j != (2 * i) / j) d.push_back((2 * i) / j);
    }
    set<int> S;
    for (int j = 0; j < d.size(); ++j) {
      if (d[j] == 1) continue;
      if (((2 * i) / d[j] - d[j] + 1) % 2 == 1) continue;
      int a1 = ((2 * i) / d[j] - d[j] + 1) / 2;
      if (a1 < 1) continue;
      int x = 0;
      for (int k = 0; k < d[j]; ++k) x ^= f[a1 + k];
      if (i == n && x == 0) odp = min(odp, d[j]);
      S.insert(x);
    }
    int mex = 0;
    while (S.find(mex) != S.end()) ++mex;
    f[i] = mex;
  }
  if (f[n] != 0)
    cout << odp;
  else
    cout << "-1";
  return 0;
}
