#include <bits/stdc++.h>
using namespace std;
int dp[100005];
int dp2[100005];
int check(int n) {
  if (dp[n] != -1) return dp[n];
  map<int, int> vis;
  int ans, ans2;
  ans = 0;
  ans2 = -1;
  for (int i = 2; 1LL * i * i <= 2 * n; i++) {
    if ((2 * n) % i) continue;
    int dt, t2;
    dt = i;
    t2 = (2 * n / dt - dt + 1);
    if (t2 < 0 || (t2 & 1)) continue;
    int t = 0;
    for (int j = t2 / 2, k = 0; k < dt; j++, k++) t ^= check(j);
    vis[t] = 1;
    if (!t && ans2 == -1) ans2 = dt;
  }
  for (ans = 0; vis[ans] == 1; ans++)
    ;
  dp[n] = ans;
  dp2[n] = ans2;
  return ans;
}
int main() {
  int n;
  memset(dp, -1, sizeof(dp));
  while (cin >> n) {
    check(n);
    printf("%d\n", dp2[n]);
  }
}
