#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 10;
int a[M];
int pre[M];
int main() {
  int n;
  cin >> n;
  int ans = -1;
  for (int i = 2; i <= n; i++) {
    set<int> g;
    for (int k = 2; k <= 450; k++) {
      int v = i - k * (k - 1) / 2;
      if (v > 0 && v % k == 0) {
        int x = v / k;
        int num = pre[x - 1] ^ pre[x + k - 1];
        g.insert(num);
        if (i == n && num == 0 && ans == -1) {
          ans = k;
        }
      }
    }
    if (g.size() > 0) {
      int num = 0;
      for (set<int>::iterator it = g.begin(); it != g.end(); it++) {
        if ((*it) == num) {
          num++;
        } else {
          break;
        }
      }
      a[i] = num;
    }
    pre[i] = pre[i - 1] ^ a[i];
  }
  if (a[n]) {
    cout << ans << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}
