#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int SQRT = 320;
int g[N];
int mark[N];
int main() {
  int n;
  cin >> n;
  int a1;
  for (int i = 1; i <= n; i++) {
    for (int k = 2; k <= SQRT; k++) {
      int d = i - k * (k - 1) / 2;
      if (d > 0 && d % k == 0) {
        int z = 0;
        a1 = d / k;
        for (int j = 0; j < k; j++) z ^= g[j + a1];
        mark[z] = i;
      }
    }
    while (mark[g[i]] == i) g[i]++;
  }
  for (int k = 2; k <= SQRT; k++) {
    int d = n - k * (k - 1) / 2;
    if (d > 0 && d % k == 0) {
      int z = 0;
      a1 = d / k;
      for (int j = 0; j < k; j++) z ^= g[j + a1];
      if (z == 0) {
        cout << k;
        return 0;
      }
    }
  }
  cout << -1;
  return 0;
}
