#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 100;
const int oo = 1e9;
int g[N];
int t;
int mex(vector<int> v) {
  v.push_back(-1);
  v.push_back(oo);
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int i = 1; i < ((int)v.size()); ++i)
    if (v[i] - v[i - 1] > 1) return v[i - 1] + 1;
  return 0;
}
vector<int> v;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 2; i <= n; ++i) {
    v.clear();
    for (int j = 2; j * j / 2 <= i; ++j) {
      int t = ((2 * i) / j - j + 1) / 2;
      if (!(j * (2 * t + j - 1) / 2 == i && t > 0)) continue;
      int x = 0;
      for (int k = t; k < t + j; ++k) x ^= g[k];
      v.push_back(x);
    }
    g[i] = mex(v);
  }
  if (!g[n]) {
    cout << "-1\n";
    return 0;
  }
  for (int j = 2; j * j / 2 <= n; ++j) {
    int t = ((2 * n) / j - j + 1) / 2;
    if (!(j * (2 * t + j - 1) / 2 == n && t > 0)) continue;
    int x = 0;
    for (int k = t; k < t + j; ++k) x ^= g[k];
    if (!x) {
      cout << j << "\n";
      return 0;
    }
  }
  return 0;
}
