#include <bits/stdc++.h>
const int N = 100010;
const int inf = 0x3f3f3f3f;
using namespace std;
int dp[N], res[N], vis[N];
void solve(int n) {
  for (int i = 2; (i + 1) * i / 2 <= n; i++) {
    if ((2 * n) % i == 0) {
      int t = 2 * n / i - i + 1;
      if ((t & 1) || t < 0) continue;
      t /= 2;
      vis[dp[t + i - 1] ^ dp[t - 1]] = n;
      if ((dp[t + i - 1] ^ dp[t - 1]) == 0)
        if (res[n] == -1) res[n] = i;
    }
  }
  dp[n] = -1;
  for (int i = 0; vis[i] == n; i++) dp[n] = i;
  dp[n]++;
  dp[n] ^= dp[n - 1];
  return;
}
int main() {
  int n;
  scanf("%d", &n);
  memset(res, -1, sizeof(res));
  for (int i = 3; i <= n; i++) solve(i);
  printf("%d\n", res[n]);
  return 0;
}
