#include <bits/stdc++.h>
using namespace std;
int sg[100005];
int sum[100005];
int vis[100005];
int main() {
  int n;
  scanf("%d", &n);
  int ans = -1;
  for (int i = 3; i <= n; ++i) {
    for (int j = 2; j * j <= (i << 1); ++j) {
      if ((i << 1) % j) continue;
      int k = (i << 1) / j + 1 - j;
      if ((k > 1) && ((k & 1) == 0)) {
        k >>= 1;
        int now = sum[k + j - 1] ^ sum[k - 1];
        if (i == n && now == 0 && ans == -1) ans = j;
        vis[now] = i;
      }
    }
    for (int o = 0;; ++o) {
      if (vis[o] != i) {
        sg[i] = o;
        sum[i] = sum[i - 1] ^ o;
        break;
      }
    }
  }
  cout << ans;
}
