#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, k, j, t, r, x;
  cin >> n;
  vector<int> v1(n + 1, 0);
  vector<int> v2(n + 2, 0);
  for (i = 2; i <= n; ++i) {
    k = 2;
    for (;;) {
      x = i - (k * (k - 1)) / 2;
      if (x < 0) {
        break;
      }
      if (x % k == 0) {
        x = x / k;
        t = 0;
        for (j = 0; j < k; ++j) {
          t = t ^ v1[x + j];
        }
        v2[t] = i;
      }
      ++k;
    }
    r = 0;
    while (v2[r] == i) {
      ++r;
    }
    v1[i] = r;
  }
  if (v1[n] == 0) {
    cout << -1 << endl;
    return 0;
  }
  k = 2;
  for (;;) {
    x = n - (k * (k - 1)) / 2;
    if (x % k == 0) {
      x = x / k;
      int t = 0;
      for (i = 0; i < k; ++i) {
        t = t ^ v1[x + i];
      }
      if (!t) {
        break;
      }
    }
    ++k;
  }
  cout << k << endl;
  return 0;
}
