#include <bits/stdc++.h>
using namespace std;
long long int dp[100001], a[100001];
long long int fun(long long int m) {
  if (m < 3) return dp[m] = 0;
  if (dp[m] != -1) return dp[m];
  dp[m] = 0;
  set<long long int> s;
  set<long long int>::iterator it;
  for (long long int i = 2; (i * (i + 1)) / 2 <= m; ++i) {
    long long int left = m - ((i * (i + 1)) / 2);
    if (left % i == 0) {
      long long int ans = 0;
      for (long long int j = 1; j <= i; ++j) ans = ans ^ fun(left / i + j);
      s.insert(ans);
    }
  }
  if (!s.empty()) {
    long long int asi = 0;
    for (it = s.begin(); it != s.end(); ++it) {
      if (*(it) == asi)
        asi++;
      else
        break;
    }
    dp[m] = asi;
  }
  return dp[m];
}
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 0; i <= n; ++i) dp[i] = -1;
  long long int ans = fun(n);
  if (ans == 0)
    printf("-1\n");
  else {
    long long int flag = -1;
    for (long long int i = 2; (i * (i + 1)) / 2 <= n; ++i) {
      long long int left = n - ((i * (i + 1)) / 2);
      if (left % i == 0) {
        long long int ans = 0;
        for (long long int j = 1; j <= i; ++j) ans = ans ^ dp[left / i + j];
        if (ans == 0) {
          flag = i;
          break;
        }
      }
    }
    cout << flag << endl;
  }
  return 0;
}
