#include <bits/stdc++.h>
using namespace std;
long long int grundy[100001];
long long int findmex(set<long long int> s1) {
  long long int count = 0;
  while (s1.find(count) != s1.end()) {
    count++;
  }
  return count;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  set<long long int> s1;
  grundy[1] = grundy[2] = 0;
  long long int consec, no, val, abc;
  for (long long int i = 3; i < 100001; i++) {
    s1.clear();
    consec = 2;
    while (1) {
      no = (consec * (consec + 1)) / 2;
      if (no > i) {
        break;
      }
      val = (i - no);
      if (val % consec != 0) {
        consec++;
        continue;
      }
      val = val / consec;
      abc = 0;
      for (long long int j = val + 1; j <= val + consec; j++) {
        abc = abc ^ grundy[j];
      }
      s1.insert(abc);
      consec++;
    }
    grundy[i] = findmex(s1);
  }
  long long int n;
  cin >> n;
  if (grundy[n] == 0) {
    cout << "-1";
    exit(0);
  }
  consec = 2;
  while (1) {
    no = (consec * (consec + 1)) / 2;
    val = (n - no);
    if (val % consec != 0) {
      consec++;
      continue;
    }
    val = val / consec;
    abc = 0;
    for (long long int j = val + 1; j <= val + consec; j++) {
      abc = abc ^ grundy[j];
    }
    if (abc == 0) {
      cout << consec;
      exit(0);
    }
    consec++;
  }
  return 0;
}
