#include <bits/stdc++.h>
using namespace std;
inline int Get() {
  int res = 0, q = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') q = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return res * q;
}
const double eps = 1e-12, pi = M_PI;
const int oo = (int)2e9, mod = (int)1e9 + 7;
const long long INF = (long long)1e17;
const int N = (int)1e5;
typedef int arr[N + 10];
int n, rd;
arr sg, v;
int main() {
  scanf(
      "%d"
      "\n",
      &n);
  sg[1] = sg[2] = 0;
  for (int i = (3), end = (n); i <= end; ++i) {
    ++rd;
    for (int k = (2), end = (n); k <= end; ++k) {
      if (k * k - k >= 2 * i) break;
      if ((k & 1) && i % k == 0) {
        int st = i / k - (k - 1) / 2;
        v[sg[st - 1] ^ sg[st + k - 1]] = rd;
      } else if (!(k & 1) && i % (k / 2) == 0) {
        if (((i / (k / 2) + 1 - k) & 1) == 0) {
          int st = (i / (k / 2) + 1 - k) >> 1;
          v[sg[st - 1] ^ sg[st + k - 1]] = rd;
        }
      }
    }
    for (int j = (0), end = (n); j <= end; ++j)
      if (v[j] != rd) {
        sg[i] = sg[i - 1] ^ j;
        break;
      }
  }
  if (!(sg[n] ^ sg[n - 1])) return printf("-1\n"), 0;
  for (int k = (2), end = (n); k <= end; ++k) {
    if (k * k - k >= 2 * n) break;
    if ((k & 1) && n % k == 0) {
      int st = n / k - (k - 1) / 2;
      if (!(sg[st - 1] ^ sg[st + k - 1]))
        return printf(
                   "%d"
                   "\n",
                   k),
               0;
    } else if (!(k & 1) && n % (k / 2) == 0) {
      if (((n / (k / 2) + 1 - k) & 1) == 0) {
        int st = (n / (k / 2) + 1 - k) >> 1;
        if (!(sg[st - 1] ^ sg[st + k - 1]))
          return printf(
                     "%d"
                     "\n",
                     k),
                 0;
      }
    }
  }
  return 0;
}
