#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, g[100005] = {}, m[100005] = {};
  cin >> n;
  for (int i = 3; i <= n; ++i) {
    int f[50] = {};
    for (int j = 2; j * (j + 1) / 2 <= i; ++j) {
      int k = 0, gi = 0;
      if ((i - (j + 1) * j / 2) % j == 0) {
        k = (i - (j + 1) * j / 2) / j + 1;
      }
      if (k) {
        for (int t = k; t < j + k; ++t) {
          gi ^= g[t];
        }
        f[gi] = true;
        if (!gi && !m[i]) m[i] = j;
      }
    }
    int j;
    for (j = 0; f[j]; ++j)
      ;
    g[i] = j;
  }
  cout << (g[n] ? m[n] : -1) << endl;
}
