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