#include <bits/stdc++.h>
using namespace std;
int n, g[1000001], ans = -1;
int sg(int x) {
  if (g[x] != -1) return g[x];
  bool used[1001];
  memset(used, false, sizeof(used));
  for (int k = 2; (k - 1) * k / 2 < x; k++) {
    int t = x - (k - 1) * k / 2;
    if (t % k != 0) continue;
    int sumXor = 0, a = t / k;
    for (int i = 1; i <= k; i++) sumXor ^= sg(a + i - 1);
    if (x == n && sumXor == 0 && ans == -1) ans = k;
    used[sumXor] = true;
  }
  for (int i = 0;; i++)
    if (!used[i]) {
      g[x] = i;
      return i;
    }
}
int main() {
  cin >> n;
  g[0] = g[1] = 0;
  for (int i = 2; i <= n; i++) g[i] = -1;
  sg(n);
  cout << ans << '\n';
  return 0;
}
