#include <bits/stdc++.h>
using namespace std;
int dyn[100000];
int Grandi(int n) {
  if (n < 100000 && dyn[n] >= 0) return dyn[n];
  double m = sqrt(2 * n);
  int ar[1000];
  for (int i = 0; i < 1000; ++i) ar[i] = 0;
  int res = -1, res1 = 0;
  for (int i = 2; i <= m; ++i) {
    res1 = 0;
    if ((i % 2) && !(n % i)) {
      for (int j = n / i - ((i - 1) >> 1); j <= n / i + ((i - 1) >> 1); ++j)
        res1 ^= Grandi(j);
      ar[res1] = 1;
    }
    if (!(i % 2) && !((n + (i >> 1)) % i)) {
      for (int j = n / i - (i >> 1) + 1; j <= n / i + (i >> 1); ++j)
        res1 ^= Grandi(j);
      ar[res1] = 1;
    }
  }
  while (ar[++res])
    ;
  if (n < 100000) dyn[n] = res;
  return res;
}
int main(int argc, char** argv) {
  int n;
  int min = 0;
  cin >> n;
  for (int i = 0; i < 100000; ++i) dyn[i] = -1;
  double m = sqrt(2 * n);
  int ar[1000];
  for (int i = 0; i < 1000; ++i) ar[i] = 0;
  int res = -1, res1 = 0;
  for (int i = 2; i <= m; ++i) {
    res1 = 0;
    if ((i % 2) && !(n % i)) {
      for (int j = n / i - ((i - 1) >> 1); j <= n / i + ((i - 1) >> 1); ++j)
        res1 ^= Grandi(j);
      ar[res1] = 1;
      if (!min && !res1) min = i;
    }
    if (!(i % 2) && !((n + (i >> 1)) % i)) {
      for (int j = n / i - (i >> 1) + 1; j <= n / i + (i >> 1); ++j)
        res1 ^= Grandi(j);
      ar[res1] = 1;
      if (!min && !res1) min = i;
    }
  }
  while (ar[++res])
    ;
  if (res)
    cout << min;
  else
    cout << "-1";
  return 0;
}
