#include <bits/stdc++.h>
using namespace std;
class Prime {
 public:
  vector<int> primes;
  Prime() { genPrime(1000000); }
  int genPrime(int N) {
    bool* mk = new bool[N + 2];
    memset(mk, 0, N + 1);
    for (int i = 2, k = 4; i <= N; i++, k += i + i - 1) {
      if (!mk[i]) {
        primes.push_back(i);
        if (k <= N)
          for (int j = i + i; j <= N; j += i) mk[j] = 1;
      }
    }
    delete[] mk;
    return primes.size();
  }
  map<long long, int> getFactors(long long N) {
    map<long long, int> factors;
    long long root = ((long long)sqrt((double)N)) + 1;
    for (unsigned int i = 0; N > 1 && i < primes.size() && primes[i] <= root;
         ++i) {
      if (N % primes[i] == 0) {
        factors[primes[i]] = 0;
        while (N % primes[i] == 0) N /= primes[i], factors[primes[i]]++;
      }
    }
    if (N > 1) factors[N] = 1;
    return factors;
  }
  map<int, int> getFactorsInt(int N) {
    map<int, int> factors;
    int root = ((int)sqrt((double)N)) + 1;
    for (unsigned int i = 0; N > 1 && i < primes.size() && primes[i] <= root;
         ++i) {
      if (N % primes[i] == 0) {
        factors[primes[i]] = 0;
        while (N % primes[i] == 0) N /= primes[i], factors[primes[i]]++;
      }
    }
    if (N > 1) factors[N] = 1;
    return factors;
  }
  map<int, int> getJieFactors(int x) {
    map<int, int> ret;
    for (int i = 0; x >= Prime::prime.primes[i]; ++i) {
      int p = Prime::prime.primes[i];
      int t = x;
      while (t >= p) {
        ret[p] += t / p;
        t /= p;
      }
    }
    return ret;
  }
  vector<int> getDivisors(int N) {
    map<int, int> factors = getFactorsInt(N);
    vector<int> p;
    vector<int> maxi;
    for (map<int, int>::iterator itr = factors.begin(); itr != factors.end();
         ++itr)
      p.push_back(itr->first), maxi.push_back(itr->second);
    vector<int> ret;
    vector<int> nowi(p.size(), 0);
    int nowp = p.size() - 1;
    while (true) {
      int now = 1;
      for (int i = 0; i < p.size(); ++i)
        for (int j = 1; j <= nowi[i]; ++j) now = now * p[i];
      ret.push_back(now);
      nowp = p.size() - 1;
      nowi[nowp]++;
      while (nowi[nowp] > maxi[nowp]) {
        nowp--;
        if (nowp < 0) return ret;
        nowi[nowp]++;
      }
      for (int i = nowp + 1; i < p.size(); ++i) nowi[i] = 0;
    }
    return ret;
  }
  static Prime prime;
};
Prime Prime::prime;
long long sg[200000];
long long xorsg[100001];
int win[200000];
void init() {
  sg[1] = 0;
  sg[2] = 0;
  memset(xorsg, 0, sizeof(xorsg));
  memset(win, -1, sizeof(win));
}
void york() {
  for (long long i = 3; i <= 100000; ++i) {
    vector<int> divs = Prime::prime.getDivisors(i * 2);
    sort(divs.begin(), divs.end());
    set<long long> nextsg;
    for (int j = 0; j < divs.size(); ++j) {
      long long k = divs[j];
      if (k >= 2 && (2 * i + k - k * k) % (k << 1) == 0) {
        long long x = (2 * i + k - k * k) / (k << 1);
        if (x >= 1) {
          long long nowsg = xorsg[x + k - 1] ^ xorsg[x - 1];
          if (nowsg == 0 && win[i] == -1) win[i] = k;
          nextsg.insert(nowsg);
        }
      }
    }
    sg[i] = 0;
    while (nextsg.find(sg[i]) != nextsg.end()) sg[i]++;
    xorsg[i] = xorsg[i - 1] ^ sg[i];
  }
  int N;
  cin >> N;
  if (sg[N] == 0)
    cout << -1 << endl;
  else
    cout << win[N] << endl;
}
int main() {
  init();
  york();
  return 0;
}
