#include <bits/stdc++.h>
using namespace std;
int dp[100000 + 5];
int pre[100000 + 5];
int gr[100000 + 5];
int main() {
  int n;
  scanf("%d", &n);
  dp[1] = dp[2] = 0;
  pre[1] = pre[2] = 0;
  for (int i = 3; i <= n; i++) {
    for (int p = 2; p <= i; p++) {
      int psm = (p * (p - 1)) / 2;
      int rem = (i - psm);
      if (rem <= 0) break;
      if (rem && (rem % p) == 0) {
        int bg = rem / p;
        int ed = bg + p - 1;
        int x = (pre[ed] ^ pre[bg - 1]);
        gr[x] = i;
      }
    }
    int ans = 0;
    while (true) {
      if (gr[ans] != i) break;
      ans++;
    }
    dp[i] = ans;
    pre[i] = pre[i - 1] ^ ans;
  }
  int k = -1;
  for (int p = 2; p <= n; p++) {
    int psm = (p * (p - 1)) / 2;
    int rem = (n - psm);
    if (rem <= 0) break;
    if (rem && rem % p == 0) {
      int bg = rem / p;
      int ed = bg + p - 1;
      if (!(pre[ed] ^ pre[bg - 1])) {
        k = p;
        break;
      }
    }
  }
  printf("%d\n", k);
  return 0;
}
