#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int f[100100];
int u[500];
int t;
int main() {
  cin >> n;
  f[1] = 0;
  for (int i = 2; i <= n; i++) {
    t++;
    for (int k = 2; k * (k + 1) <= 2 * i; k++) {
      if ((i - k * (k + 1) / 2) % k == 0) {
        int m = 0;
        int a = (i - k * (k + 1) / 2) / k + 1;
        for (int j = 0; j < k; j++) m ^= f[a++];
        u[m] = t;
      }
    }
    for (int j = 0; j < (500); j++)
      if (u[j] != t) {
        f[i] = j;
        break;
      }
  }
  if (f[n] == 0)
    cout << -1 << endl;
  else {
    int i = n;
    for (int k = 2; k * (k + 1) <= 2 * i; k++) {
      if ((i - k * (k + 1) / 2) % k == 0) {
        int m = 0;
        int a = (i - k * (k + 1) / 2) / k + 1;
        for (int j = 0; j < k; j++) m ^= f[a++];
        if (m == 0) {
          cout << k << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}
