#include <bits/stdc++.h>
using namespace std;
int dp[100010];
int solve(int n) {
  if (dp[n] != -1) return dp[n];
  int m = 2, a, i, sum, ans, yy = -1;
  vector<int> bb;
  bb.clear();
  while (2 * n / m + 1 - m > 0) {
    if (2 * n % m != 0 || (2 * n / m + 1 - m) % 2 != 0) {
      m++;
      continue;
    }
    a = (2 * n / m + 1 - m) / 2;
    sum = 0;
    for (i = a; i < a + m; i++) {
      solve(i);
      sum ^= dp[i];
    }
    if (sum == 0 && yy == -1) yy = m;
    bb.push_back(sum);
    m++;
  }
  dp[n] = 0;
  sort(bb.begin(), bb.end());
  for (i = 0; i < bb.size(); i++) {
    if (bb[i] == dp[n])
      dp[n]++;
    else if (bb[i] > dp[n])
      break;
  }
  return yy;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    memset(dp, -1, sizeof(dp));
    printf("%d\n", solve(n));
  }
}
