#include <bits/stdc++.h>
using namespace std;
multimap<int, pair<int, int> > Map;
const int sz = 100100;
int n;
int g[sz];
int was[sz];
int cur;
int x[sz];
int ans[sz];
int main() {
  scanf("%d", &n);
  for (int i = 1; i < sz; ++i)
    for (int j = i + 1, s = i + i + 1; s < sz; s += ++j)
      Map.insert(make_pair(s, make_pair(i, j)));
  g[0] = 0;
  multimap<int, pair<int, int> >::iterator it = Map.begin();
  for (int i = 1; i < sz; ++i) {
    ++cur;
    ans[i] = 100100;
    while (it != Map.end() && it->first == i) {
      int s = it->second.first;
      int e = it->second.second;
      int t = x[e] ^ x[s - 1];
      was[t] = cur;
      if (t == 0) ans[i] = min(ans[i], e - s + 1);
      ++it;
    }
    g[i] = 0;
    while (was[g[i]] == cur) ++g[i];
    x[i] = x[i - 1] ^ g[i];
  }
  if (ans[n] > n) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans[n] << endl;
  return 0;
}
