#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const long long inf = 1e17 + 7;
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  cout.precision(10);
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  vector<long long> pref(n + 1);
  long long res = inf;
  for (long long i = 3; i <= n; i++) {
    vector<long long> b;
    for (long long len = 2; len * len <= 2 * i; len++) {
      long long st = i - len * (len - 1) / 2;
      if (st % len != 0 || st == 0) continue;
      st /= len;
      long long num = pref[st + len - 1] ^ pref[st - 1];
      b.emplace_back(num);
      if (i == n && num == 0 && res == inf) res = len;
    }
    sort(b.begin(), b.end());
    b.emplace_back(inf);
    long long last = -1;
    for (long long j : b) {
      if (j == last) continue;
      if (j != ++last) {
        a[i] = last;
        break;
      }
    }
    pref[i] = pref[i - 1] ^ a[i];
  }
  cout << endl;
  if (res == inf)
    cout << -1;
  else
    cout << res;
}
