#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> ks;
bool ok(int x, int cn) {
  if (2 * cn % x) {
    return 0;
  }
  if (2 * cn / x - (x - 1) <= 0) {
    return 0;
  }
  if ((2 * cn / x - (x - 1)) % 2) {
    return 0;
  }
  return 1;
}
int mem[100042];
bool used[100042];
int sg(int cn) {
  if (used[cn]) {
    return mem[cn];
  }
  used[cn] = 1;
  bool able[50042];
  for (int i = 0; i < 50042; i++) {
    able[i] = 0;
  }
  for (int k = 2; k * k <= 2 * cn; k++) {
    if (!ok(k, cn)) {
      continue;
    }
    int xsum = 0;
    int a1 = (2 * cn / k - (k - 1)) / 2, sum = a1;
    if (a1 < 0) {
      int kk;
      cin >> kk;
    }
    xsum = sg(a1);
    for (int i = 1; sum != cn; i++) {
      xsum ^= sg(a1 + i);
      sum += a1 + i;
    }
    if (xsum == 0 && cn == n) {
      cout << k << "\n";
      return 1;
    }
    able[xsum] = 1;
  }
  int res = 0;
  for (int i = 0; i < 50042; i++) {
    if (!able[i]) {
      res = i;
      break;
    }
  }
  mem[cn] = res;
  return mem[cn];
}
int main() {
  cin >> n;
  if (sg(n) == 0) {
    cout << "-1\n";
  }
  return 0;
}
