#include <bits/stdc++.h>
using namespace std;
int gr[100009];
int findgr(int n) {
  if (gr[n] != -1) return gr[n];
  int sum, v;
  int vis[1000] = {0};
  for (int i = 2;; i++) {
    sum = n;
    sum -= (i * (i - 1)) / 2;
    if (sum < 0) break;
    if (sum % i == 0) {
      v = 0;
      int a = sum / i;
      int b = a + i;
      for (int k = a; k < b; k++) {
        v = v ^ gr[k];
      }
      vis[v] = 1;
    }
  }
  int i;
  for (i = 0; vis[i]; i++) {
  }
  return i;
}
void find(int n) {
  int i;
  for (i = 3; i <= n + 1; i++) {
    gr[i] = findgr(i);
  }
}
int main() {
  int n;
  cin >> n;
  memset(gr, -1, sizeof(gr));
  gr[0] = gr[1] = gr[2] = 0;
  find(n);
  int ans = -1;
  if (gr[n] != 0) {
    int i;
    for (i = 2;; i++) {
      int a = (n - (i * (i - 1) / 2)) / i;
      if (a >= 1 && i * a + (i * (i - 1) / 2) == n) {
        int b = a + i, v = 0;
        for (int k = a; k < b; k++) {
          v = v ^ gr[k];
        }
        if (v == 0) {
          ans = i;
          break;
        }
      }
      if (ans > -1) break;
    }
  }
  cout << ans << "\n";
  return 0;
}
