#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
const int N = 2e5 + 5;
int grundy[N];
int pre[N];
int mex(set<int> se) {
  for (int i = 0;; i++)
    if (!se.count(i)) return i;
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int res = -1;
  for (int i = 1; i <= n; i++) {
    set<int> se;
    for (int k = 2;; k++) {
      if (k * (k + 1) / 2 > i) break;
      int x = (i - k * (k - 1) / 2);
      if (x % k) continue;
      x /= k;
      int l = x;
      int r = x + k - 1;
      int cur = pre[r] ^ pre[l - 1];
      se.insert(cur);
      if (i == n && cur == 0 && res == -1) res = k;
    }
    grundy[i] = mex(se);
    pre[i] = pre[i - 1] ^ grundy[i];
  }
  cout << res << "\n";
  return 0;
}
