#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int N = 200001;
vector<long long int> divi[N];
long long int pre[N];
set<long long int> g;
signed main() {
  long long int n;
  scanf("%lld", &n);
  for (long long int i = 1; i < N; i++)
    for (long long int j = i; j < N; j += i) divi[j].emplace_back(i);
  long long int kk;
  for (long long int i = 1; i <= n; i++) {
    g.clear();
    kk = -1;
    for (long long int k : divi[2 * i]) {
      if (k > 1) {
        if ((i - (k * (k - 1)) / 2) % k != 0) continue;
        long long int l = (i - (k * (k - 1)) / 2) / k;
        if (l > 0 && l + k - 1 < n) {
          g.insert((pre[l + k - 1] ^ pre[l - 1]));
          if (kk == -1 && (pre[l + k - 1] ^ pre[l - 1]) == 0) kk = k;
        }
      }
    }
    for (long long int j = 0;; j++) {
      if (!g.count(j)) {
        pre[i] = j;
        break;
      }
    }
    pre[i] ^= pre[i - 1];
  }
  if (pre[n] == pre[n - 1])
    puts("-1");
  else {
    printf("%lld", kk);
  }
  return 0;
}
