#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
const int MOD = 1e9 + 7;
int ans[N], grundy[N];
int solve2(int a, int b) { return b * (b + 1) / 2 - a * (a + 1) / 2; }
int ss(int idx, int x) { return (idx * 2 - x - (x * x)) / (2 * x); }
int mex(set<int>& st) {
  int cnt = 0;
  while (st.count(cnt)) cnt++;
  return cnt;
}
vector<pair<int, int>> v[N];
int solve(int idx) {
  set<int> st;
  for (int i = 2; i <= idx; i++) {
    if (solve2(0, 0 + i) > idx) break;
    int val = ss(idx, i);
    int j2 = 0;
    int val2 = solve2(val, val + i);
    if (val2 == idx) {
      for (int j = val + 1; j <= val + i; j++) j2 ^= grundy[j];
      st.insert(j2);
    }
  }
  grundy[idx] = mex(st);
  return grundy[idx];
}
void print(int idx) {
  for (int i = 2; i <= idx; i++) {
    if (solve2(0, 0 + i) > idx) break;
    int val = ss(idx, i);
    int j2 = 0;
    int val2 = solve2(val, val + i);
    if (val2 == idx) {
      for (int j = val + 1; j <= val + i; j++) j2 ^= grundy[j];
      if (!j2) {
        cout << i << endl;
        return;
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  memset(ans, -1, sizeof ans);
  ans[0] = ans[1] = ans[2] = 0;
  for (int i = 2; i <= n; i++) {
    solve(i);
  }
  if (grundy[n] == 0) {
    cout << -1 << endl;
  } else {
    print(n);
  }
}
