#include <bits/stdc++.h>
using namespace std;
const int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
const int dj[] = {0, 1, 0, -1, -1, 1, -1, 1};
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long double EPS = 1e-7;
inline long long sum(long long x) { return x * (x + 1) / 2; }
inline int mex(set<int>& st) {
  int c = 0;
  for (auto& i : st) {
    if (c != i) break;
    c++;
  }
  return c;
}
vector<int> mem(1e5 + 5, -1);
int grundy(int x) {
  int& ret = mem[x];
  if (~ret) return ret;
  ret = 0;
  set<int> st;
  for (long long i = 2; sum(i) <= x; i++) {
    if ((x - sum(i)) % i == 0) {
      int tmp = 0;
      for (int j = 1; j <= i; j++) {
        tmp ^= grundy(j + (x - sum(i)) / i);
      }
      st.insert(tmp);
    }
  }
  return ret = mex(st);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  int r = -1;
  for (long long i = 2; sum(i) <= n; i++) {
    int x = 0;
    if ((n - sum(i)) % i == 0) {
      for (int j = 1; j <= i; j++) {
        x ^= grundy(j + (n - sum(i)) / i);
      }
      if (!x) {
        r = i;
        break;
      }
    }
  }
  cout << r << endl;
  cin.ignore(), cin.get();
}
