#include <bits/stdc++.h>
using namespace std;
int sg[100005], sgp[100005];
int main() {
  int n;
  cin >> n;
  if (n <= 2) {
    cout << "-1";
    return 0;
  }
  sg[0] = sg[1] = sg[2] = 0;
  for (int i = 3; i <= n; ++i) {
    int cnt[105] = {0};
    for (int d = 2; d <= i; ++d) {
      int fr, ls;
      if (d % 2 == 0) {
        fr = i / d - d / 2 + 1, ls = i / d + d / 2;
        if (ls >= i || fr <= 0) break;
        if ((fr + ls) * d / 2 != i) continue;
      }
      if (d % 2 == 1) {
        fr = i / d - (d - 1) / 2, ls = i / d + (d - 1) / 2;
        if (ls >= i || fr <= 0) break;
        if (i % d != 0) continue;
      }
      cnt[sgp[fr - 1] ^ sgp[ls]] = 1;
      if (i == n && (sgp[fr - 1] ^ sgp[ls]) == 0) {
        cout << d;
        return 0;
      }
    }
    for (int j = 0; j < 100000; ++j)
      if (cnt[j] == 0) {
        sg[i] = j;
        sgp[i] = sgp[i - 1] ^ sg[i];
        break;
      }
  }
  cout << "-1";
}
