#include <bits/stdc++.h>
using namespace std;
int n;
int G[100002];
int PX[100002];
int s[100002];
bool vis[1000005];
int cx, g, a;
int main() {
  scanf("%d", &n);
  for (int i = 3; i <= n; i++) {
    memset(vis, false, 1200);
    for (int k = 2; (k * (k - 1) / 2) <= i; k++) {
      a = i - ((k * (k - 1)) / 2);
      if (a < 1) continue;
      a /= k;
      if ((a * k + (k * (k - 1)) / 2) != i) continue;
      g = PX[a + k - 1] ^ PX[a - 1];
      vis[g] = true;
    }
    int j = 0;
    for (; vis[j]; j++) {
    }
    G[i] = j;
    PX[i] = PX[i - 1] ^ j;
  }
  if (G[n] == 0)
    printf("-1\n");
  else {
    for (int k = 2; (k * (k - 1) / 2) <= n; k++) {
      a = n - ((k * (k - 1)) / 2);
      if (a % k != 0) continue;
      a /= k;
      if ((a * k + (k * (k - 1)) / 2) != n) continue;
      g = PX[a + k - 1] ^ PX[a - 1];
      if (g == 0) {
        printf("%d\n", k);
        return 0;
      }
    }
  }
  return 0;
}
