#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, sg[N], s[N];
bool vis[N];
int main() {
  sg[0] = s[0] = sg[1] = s[1] = 0;
  int tmp = 0;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int t = 0;
    vis[0] = false;
    for (int j = 1; j <= i; j++) {
      t += j;
      if (t > i) break;
      vis[j] = false;
    }
    t = 0;
    tmp = 0;
    for (int j = 1; j <= i; j++) {
      t += j;
      if (t > i) break;
      if ((i - t) % j == 0 && j > 1) {
        int d = (i - t) / j;
        int S = s[j + d] ^ s[d];
        if (!S && !tmp) tmp = j;
        vis[S] = true;
      }
    }
    for (int j = 0; j <= i; j++)
      if (!vis[j]) {
        sg[i] = j;
        break;
      }
    s[i] = s[i - 1] ^ sg[i];
  }
  if (sg[n])
    printf("%d\n", tmp);
  else
    printf("-1\n");
  return 0;
}
