#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double eps = (1e-9);
const int MAX_N = 100001;
int dp[MAX_N];
int ans, ini;
int exist[MAX_N], vid;
int sumXor[MAX_N];
void pre() {
  for (int s = 2; s <= ini; ++s) {
    ++vid;
    for (int n = 2; 1LL * n * (n + 1) <= 2 * s; ++n) {
      int num = 2 * s - n * n + n;
      if (num >= 1 && num % (2 * n) == 0) {
        int l = num / (2 * n);
        int nxtPile = sumXor[l + n - 1] ^ sumXor[l - 1];
        exist[nxtPile] = vid;
        if (!nxtPile && s == ini && ans == -1) ans = n;
      }
    }
    while (exist[dp[s]] == vid) dp[s]++;
    sumXor[s] = sumXor[s - 1] ^ dp[s];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> ini;
  ans = -1;
  pre();
  cout << ans << '\n';
}
