#include <bits/stdc++.h>
using namespace std;
int sg[100005], dp[100005], a[20], n;
void solve() {
  for (int i = 3; i < 100005; i++) {
    for (int j = 0; j < 20; j++) a[j] = 0;
    int f = 0;
    for (int j = 2; j * (j - 1) / 2 < i; j++) {
      if ((i - j * (j - 1) / 2) % j == 0) {
        int t = (i - j * (j - 1) / 2) / j;
        f = 1;
        a[dp[t - 1] ^ dp[t + j - 1]] = 1;
      }
    }
    if (f == 0) {
      dp[i] = dp[i - 1];
      continue;
    }
    int j = 0;
    while (a[j]) j++;
    sg[i] = j;
    dp[i] = dp[i - 1] ^ sg[i];
  }
  cin >> n;
  if (sg[n] == 0) cout << -1 << endl;
  for (int j = 2; j * (j - 1) / 2 < n; j++) {
    if ((n - j * (j - 1) / 2) % j == 0) {
      int t = (n - j * (j - 1) / 2) / j;
      if ((dp[t - 1] ^ dp[t + j - 1]) == 0) {
        cout << j << endl;
        return;
      }
    }
  }
}
int main() {
  solve();
  return 0;
}
