#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
int sg[N], mex[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int ans = -1;
  int cnt = 1;
  for (int i = 3; i <= n; i++) {
    for (int m = 2;; m++) {
      int k = i - m * (m + 1) / 2;
      if (k < 0) break;
      if (k % m) continue;
      int g = 0;
      for (int j = 1; j <= m; j++) g ^= sg[k / m + j];
      if (g == 0 && i == n && ans < 0) ans = m;
      mex[g] = cnt;
    }
    for (int j = 0;; j++) {
      if (mex[j] != cnt) {
        sg[i] = j;
        cnt++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
