#include <bits/stdc++.h>
using namespace std;
long long int n, a[100001], b[100001], ans = -1, i, j, k, rem, x, r;
int main() {
  cin >> n;
  for (i = 2; i <= n; i++) {
    for (j = 2; j * (j + 1) / 2 <= i; j++) {
      rem = i - j * (j + 1) / 2;
      if (rem % j) continue;
      x = 0;
      rem /= j;
      for (k = 1; k <= j; k++) x ^= a[rem + k];
      if (!x && (i == n && ans < 0)) ans = j;
      b[x] = i;
    }
    r = 0;
    while (b[r] == i) r++;
    a[i] = r;
  }
  cout << ans;
}
