#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int t, n, m, dp[1000005] = {0}, xr = 0;
long long int grundy(long long int num) {
  if (dp[num] != -1) return dp[num];
  if (num <= 2) return dp[num] = 0;
  long long int i, j;
  set<long long int> st;
  for (i = 2; i <= 450; i++) {
    long long int rem = num - ((i * (i - 1)) / 2);
    if (rem % i) continue;
    if (rem <= 0) break;
    long long int x = rem / i, gg = 0;
    for (j = x; j <= x + i - 1; j++) gg = (gg ^ grundy(j));
    st.insert(gg);
  }
  i = 0;
  while (st.find(i) != st.end()) i++;
  return dp[num] = i;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, x, y;
  cin >> n;
  memset(dp, -1, sizeof dp);
  x = grundy(n);
  if (x == 0) {
    cout << "-1";
    return 0;
  }
  for (i = 2; i <= 450; i++) {
    long long int rem = n - ((i * (i - 1)) / 2);
    if (rem % i) continue;
    if (rem <= 0) break;
    x = rem / i;
    long long int gg = 0;
    for (j = x; j <= x + i - 1; j++) gg = (gg ^ grundy(j));
    if (gg == 0) {
      cout << i;
      return 0;
    }
  }
  return 0;
}
