#include <bits/stdc++.h>
using namespace std;
int f[100001], d[40], sor[100001];
int n, kq;
bool solve(int a, int b, int &x, int &y) {
  if (a % 2 != b % 2) return false;
  y = (a + b) / 2;
  x = (a - b) / 2;
  return true;
}
int main() {
  scanf("%d", &n);
  kq = -1;
  for (int i = 3; i < n + 1; i++) {
    memset(d, false, sizeof(d));
    for (int j = 2; j * j <= 2 * i; j++)
      if ((2 * i) % j == 0) {
        int x, y;
        if (solve((2 * i) / j, j - 1, x, y)) {
          d[sor[y] ^ sor[x - 1]] = true;
          if (i == n && sor[y] == sor[x - 1])
            if (kq == -1 || j < kq) kq = j;
        }
      }
    for (int j = 0; j < 40; j++)
      if (!d[j]) {
        f[i] = j;
        sor[i] = sor[i - 1] ^ j;
        if (i == n && f[i] == 0) kq = -1;
        break;
      }
  }
  cout << kq << endl;
  return 0;
}
