#include <bits/stdc++.h>
using namespace std;
int n;
int dp[100007];
int getGrundy(int x) {
  if (dp[x] != -1) return dp[x];
  if (x == 1) return dp[x] = 0;
  set<int> st;
  for (int k = 2;; k++) {
    int r = (k * (k + 1)) / 2;
    if (r > x) break;
    if ((x - r) % k) continue;
    int g = 0, m = (x - r) / k;
    for (int j = 1; j <= k; j++) g ^= getGrundy(m + j);
    st.insert(g);
  }
  for (int i = 0;; i++)
    if (st.count(i) == 0) return dp[x] = i;
}
void generateGrundy() {
  for (int i = 1; i <= n; i++) {
    getGrundy(i);
  }
}
int main() {
  cin >> n;
  memset(dp, -1, sizeof dp);
  generateGrundy();
  if (dp[n] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int k = 2;; k++) {
    int r = (k * (k + 1)) / 2;
    if ((n - r) % k) continue;
    int g = 0, m = (n - r) / k;
    for (int j = 1; j <= k; j++) g ^= getGrundy(m + j);
    if (g == 0) {
      cout << k << endl;
      return 0;
    }
  }
  return 0;
}
