#include <bits/stdc++.h>
using namespace std;
long long xoor[(int)1e5 + 10];
int answer[(int)1e5 + 10];
bool flag1 = false;
int a = 1e9;
int gr[(int)1e5 + 10];
int n;
int dp[(int)1e5 + 10];
int solve1(int x) {
  if (dp[x] != -1) return dp[x];
  bool flag = false;
  int e = 0;
  set<int> g;
  for (int i = 2; (i * (i - 1)) / 2 < x; i++) {
    long long sum = (i * (i - 1)) / 2;
    int ans = x - sum;
    long long out = 0;
    if (ans % i == 0) {
      flag = true;
      for (int j = (ans / i * 1.0); j < (ans * 1.0 / i) + i; j++)
        out ^= solve1(j);
      if (out == 0) {
        if (answer[x] == -1) answer[x] = i;
        answer[x] = min(answer[x], i);
      }
      g.insert(out);
    }
  }
  int ff = 0;
  while (g.count(ff)) ff++;
  return dp[x] = ff;
}
int main() {
  while (cin >> n) {
    memset(dp, -1, sizeof dp);
    memset(answer, -1, sizeof answer);
    flag1 = false;
    solve1(n);
    cout << answer[n] << endl;
  }
  return 0;
}
