#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > arr[100100];
long long calc(long long i) { return i * (i + 1) / 2; }
int grundy[100100], out[100100];
int main() {
  memset(out, -1, sizeof out);
  for (int k = 2; k < 100100; ++k) {
    for (int i = 1; i < 100100; ++i) {
      long long sum = calc(i + k - 1) - calc(i - 1);
      if (sum >= 100100) break;
      arr[sum].push_back(pair<int, int>(i, k));
    }
  }
  for (int i = 2; i < 100100; ++i) {
    set<int> st;
    for (int j = 0; j < arr[i].size(); ++j) {
      int xr = 0;
      for (int z = arr[i][j].first; z < arr[i][j].first + arr[i][j].second;
           ++z) {
        xr ^= grundy[z];
      }
      st.insert(xr);
      if ((!xr) && out[i] == -1) out[i] = arr[i][j].second;
    }
    while (st.find(grundy[i]) != st.end()) ++grundy[i];
  }
  int n;
  scanf("%d", &n);
  if (~out[n])
    cout << out[n];
  else
    cout << -1;
}
