#include <bits/stdc++.h>
using namespace std;
int g[100001];
int main() {
  int n, ans = -1;
  scanf("%d", &n);
  for (int i = 3; i <= n; i++) {
    bool tag[50] = {};
    for (int m = 2;; m++) {
      int r = i - m * (m + 1) / 2;
      if (r < 0) break;
      if (r % m) continue;
      int sg = 0;
      for (int k = 1; k <= m; k++) sg ^= g[r / m + k];
      if (!sg && i == n && ans < 0) ans = m;
      tag[sg] = true;
    }
    while (tag[g[i]]) g[i]++;
  }
  printf("%d\n", ans);
}
