#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, sg[N], f[N], sum[N];
int main() {
  int res = -1;
  cin >> n;
  sg[1] = sg[2] = 0;
  for (int i = 3; i <= n; i++) {
    for (int j = 2; j * j <= 2 * i; j++) {
      if (2 * i % j == 0) {
        int k = 2 * i / j - (j - 1);
        if (k > 0 && k % 2 == 0) {
          k /= 2;
          int temp = sum[k + j - 1] ^ sum[k - 1];
          f[temp] = i;
          if (i == n && !temp && res == -1) res = j;
        }
      }
    }
    for (int j = 0;; j++) {
      if (f[j] != i) {
        sg[i] = j;
        sum[i] = sum[i - 1] ^ sg[i];
        break;
      }
    }
  }
  cout << res << endl;
  return 0;
}
