#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int G[100001];
  G[0] = 0;
  G[1] = 0;
  G[2] = 0;
  int A[100001];
  memset((A), 0, sizeof(A));
  int xo;
  int l;
  for (int i = 3; i <= n; ++i) {
    int k = 2, o, opt;
    int reza = 1;
    int mm = 0;
    while (k + reza <= i) {
      o = i - reza;
      if (o % k == 0) {
        opt = o / k;
        xo = 0;
        for (l = opt; l < opt + k; l++) {
          xo ^= G[l];
        }
        if (i == 15) {
        }
        A[xo] = 1;
        mm = max(mm, xo);
      }
      reza += k;
      k++;
    }
    for (int j = 0; j < 100001; ++j) {
      if (A[j] == 0) {
        G[i] = j;
        for (int p = 0; p < mm + 1; p++) A[p] = 0;
        break;
      }
    }
  }
  if (G[n] != 0) {
    int k = 2, o, opt;
    int reza = 1;
    while (k + reza <= n) {
      o = n - reza;
      if (o % k == 0) {
        opt = o / k;
        int xo = 0;
        for (int l = opt; l < opt + k; l++) {
          xo ^= G[l];
        }
        if (xo == 0) {
          cout << k << endl;
          return 0;
        }
      }
      reza += k;
      k++;
    }
    cerr << "FATAL" << endl;
    exit(1);
  } else {
    cout << -1 << endl;
  }
  return 0;
}
