#include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000;
int ar[100009];
int gres[100009];
int n;
int main() {
  scanf("%d", &n);
  memset(gres, -1, sizeof(gres));
  ;
  ar[0] = 0;
  ar[1] = 0;
  vector<int> v(30, 0);
  for (int i = 2; i <= n; i++) {
    v.assign(30, 0);
    for (int n = 2; n <= i; n++) {
      int x = 0;
      int t = n * (n + 1) / 2;
      if (t > i) break;
      if ((i - t) % n == 0) {
        int a = (i - t) / n;
        int k = a;
        x = ar[k + n] ^ ar[k];
        v[x] = 1;
      }
    }
    int ok = 0;
    for (int j = 0; j < 30; j++) {
      if (v[j]) continue;
      ok = j;
      break;
    }
    if (ok == 0) {
    } else {
      ar[i] = ok;
    }
    ar[i] = ar[i] ^ ar[i - 1];
  }
  long long i = n;
  if (ar[n]) {
    for (long long n = 2; n <= i; n++) {
      long long x = 0;
      long long t = n * (n + 1) / 2;
      if (t > i) break;
      if ((i - t) % n == 0) {
        long long a = (i - t) / n;
        x = ar[a + n] ^ ar[a];
        if (x == 0) {
          gres[i] = n;
          break;
        }
      }
    }
  }
  printf("%d", gres[i]);
  return 0;
}
