#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
int sg[100001], mex[100001], _xor[100001];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; ++i) {
      for (int k = 2;; ++k) {
        int mul = k * (k - 1) / 2;
        if (mul >= i) break;
        if ((i - mul) % k) continue;
        int a = (i - mul) / k;
        int t = _xor[a + k - 1] ^ _xor[a - 1];
        mex[t] = i;
      }
      for (int j = 0;; ++j) {
        if (mex[j] != i) {
          sg[i] = j;
          break;
        }
      }
      _xor[i] = _xor[i - 1] ^ sg[i];
    }
    if (!sg[n]) {
      printf("-1\n");
    } else {
      int k = 2;
      for (;; ++k) {
        int mul = k * (k - 1) / 2;
        if ((n - mul) % k) continue;
        int a = (n - mul) / k;
        int t = _xor[a + k - 1] ^ _xor[a - 1];
        if (!t) break;
      }
      printf("%d\n", k);
    }
  }
  return 0;
}
