#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535897932384626433832795;
const int inf = 1e9;
const long long inf2 = 1e18;
const int mod = 1e9 + 7;
void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve() {
  int n;
  cin >> n;
  vector<int> dp(n + 1, 0), ans(n + 1, -1), xr(n + 1, 0);
  for (int i = 3; i < n + 1; ++i) {
    set<int> second;
    for (int j = 2; j <= i; j++) {
      int x = ((j - 1) * j) / 2;
      if (x > i) break;
      x += i;
      if (x % j == 0) {
        int y = x / j;
        int z = y - j;
        if (ans[i] == -1 && (xr[z] ^ xr[y]) == 0) {
          ans[i] = j;
        }
        second.insert(xr[z] ^ xr[y]);
      }
    }
    int cnt = 0;
    for (auto x : second) {
      if (x != cnt) {
        dp[i] = cnt;
        break;
      }
      cnt++;
    }
    dp[i] = cnt;
    if (dp[i] == 0) ans[i] = -1;
    xr[i] = xr[i - 1] ^ dp[i];
  }
  cout << ans[n] << endl;
  return;
}
int main() {
  boost();
  int tc = 1;
  while (tc--) solve();
  return 0;
}
