#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 20);
int n;
void read() { cin >> n; }
int dp[MAXN];
int sol(int val, int k) {
  int ret = (2 * val + k - k * k) / (2 * k);
  if (ret * (2 * k) != (2 * val + k - k * k)) return -1;
  if (ret == 0) return -1;
  return ret;
}
int ans[MAXN];
int idx[MAXN];
inline int sum(int x) { return x * (x + 1) / 2; }
void solve() {
  dp[1] = 0;
  ans[1] = -1;
  dp[2] = 0;
  ans[2] = -1;
  for (int i = 3; i <= n; i++) {
    int val = 0;
    ans[i] = -1;
    for (int k = 2; (k * k) / 2 <= i; k++) {
      int c = sol(i, k);
      if (c == -1) continue;
      if (sum(c + k - 1) - sum(c - 1) != i) continue;
      idx[dp[c + k - 1] ^ dp[c - 1]] = i;
      if ((dp[c + k - 1] ^ dp[c - 1]) == 0 && ans[i] == -1) ans[i] = k;
    }
    for (val = 0; idx[val] == i; val++)
      ;
    dp[i] = dp[i - 1] ^ val;
  }
  cout << ans[n] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
