#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 10;
int n, gr[N], ans = -1, vis[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  for (int i = 3; i <= n; i++) {
    for (int j = 2; 1ll * j * (j + 1) / 2 <= i; j++) {
      int sm = i - j * (j + 1) / 2, sv, res = 0;
      if (sm % j) continue;
      sv = sm / j;
      for (int k = 1; k <= j; k++) res ^= gr[sv + k];
      vis[res] = i;
      if (!res && i == n && ans == -1) ans = j;
    }
    int pl = 0;
    for (; vis[pl] == i; pl++)
      ;
    gr[i] = pl;
  }
  cout << ans << '\n';
}
