#include <bits/stdc++.h>
using namespace std;
const long maxn = 100005;
long f[maxn];
long n, q, k, a1;
vector<long> was;
int main() {
  scanf("%ld", &n);
  f[1] = 0;
  f[2] = 0;
  for (long it = 3; it <= n; it++) {
    was.resize(0);
    long s = it;
    long cht = 0;
    for (k = 2; true; k++) {
      if ((2 + k - 1) * k > 2 * s) break;
      if (2 * s % k == 0) {
        long temp = 2 * s / k - k + 1;
        if (temp % 2 == 0) {
          a1 = temp / 2;
          long now = f[a1];
          for (long choice = a1 + 1; choice <= a1 + k - 1; choice++)
            now = now ^ f[choice];
          cht++;
          was.push_back(now);
        }
      }
    }
    if (cht == 0)
      f[it] = 0;
    else {
      sort(was.begin(), was.end());
      if (was[0] != 0)
        f[it] = 0;
      else if (cht == 1)
        f[it] = 1;
      else {
        bool pp = false;
        for (q = 1; q <= cht - 1; q++)
          if (was[q] - was[q - 1] > 1) {
            f[it] = was[q - 1] + 1;
            pp = true;
            break;
          }
        if (pp == false) f[it] = was[cht - 1] + 1;
      }
    }
  }
  if (f[n] == 0)
    printf("-1");
  else {
    long s = n;
    for (k = 2; true; k++) {
      if (2 * s % k == 0) {
        long temp = 2 * s / k - k + 1;
        if (temp % 2 == 0) {
          a1 = temp / 2;
          long now = f[a1];
          for (long choice = a1 + 1; choice <= a1 + k - 1; choice++)
            now = now ^ f[choice];
          if (now == 0) break;
        }
      }
    }
    printf("%ld", k);
  }
}
