#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  if (n <= 2) return cout << -1, 0;
  vector<long long> dp(n + 1), mark(n + 1);
  vector<long long> prexor(n + 1);
  for (long long i = 3; i <= n; i++) {
    for (long long k = 2; k <= i; k++) {
      long long st = ((i + ((k & 1) ? 0 : (k >> 1))) / k) - (k / 2);
      if (st <= 0) break;
      long long sm = k * (2 * st + k - 1) / 2;
      if (sm == i) {
        mark[prexor[st - 1] ^ prexor[st + k - 1]] = i;
        if (i == n && ((prexor[st - 1] ^ prexor[st + k - 1]) == 0))
          return cout << k, 0;
      }
    }
    long long curr = 0;
    while (mark[curr] == i) curr++;
    dp[i] = curr;
    prexor[i] = prexor[i - 1] ^ dp[i];
  }
  cout << -1;
  return 0;
}
