#include <bits/stdc++.h>
using namespace std;
int grundy[111111] = {0};
int main() {
  int n, m, i, j, k;
  scanf("%d", &n);
  static vector<int> minDiv(n + 1, 1000000000);
  static vector<int> seen(n + 1, -1);
  for (i = 3; i <= n; ++i) {
    for (j = 2; j * (j + 1) / 2 <= i; ++j) {
      int f = i - (j - 1) * j / 2;
      if (f % j != 0) continue;
      f /= j;
      int grundysVal = 0;
      for (k = 0; k < j; ++k) grundysVal ^= grundy[f + k];
      if (grundysVal == 0) minDiv[i] = minDiv[i] < j ? minDiv[i] : j;
      seen[grundysVal] = i;
    }
    while (seen[grundy[i]] == i) grundy[i]++;
  }
  if (minDiv[n] == 1000000000)
    puts("-1");
  else
    printf("%d\n", minDiv[n]);
  return 0;
}
