#include <bits/stdc++.h>
using namespace std;
int grundy[100001];
int g(int n, bool rec) {
  if (grundy[n] >= 0) {
    return grundy[n];
  }
  set<int> s;
  for (int i = 2; i * i <= 2 * n; i++) {
    if (2 * n % i) continue;
    int c = 2 * n / i;
    if ((c + i - 1) % 2) continue;
    int a = (c - i + 1) / 2, b = (c + i - 1) / 2;
    int xx = 0;
    for (int j = a; j <= b; j++) {
      xx ^= g(j, false);
    }
    s.insert(xx);
    if (rec && xx == 0) {
      cout << i << endl;
      return 0;
    }
  }
  if (rec) {
    cout << -1 << endl;
  }
  for (int i = 0;; i++) {
    if (s.count(i) == 0) return grundy[n] = i;
  }
  return -1;
}
int main() {
  memset(grundy, -1, sizeof(grundy));
  grundy[0] = grundy[1] = grundy[2] = 0;
  long n = 100;
  cin >> n;
  if (n > 2) {
    g(n, true);
  } else {
    cout << -1 << endl;
  }
  return 0;
}
