#include <bits/stdc++.h>
using namespace std;
int dp[100100], sx[100100], mn[100100], us[100100];
int main(void) {
  int n;
  scanf("%d", &n);
  dp[0] = 0;
  sx[0] = 0;
  for (int i = (1); i < (n + 1); ++i) {
    memset(us, 0, sizeof(int) * 500);
    for (int j = 2; j * (j + 1) <= 2 * i; ++j) {
      int k = i - (j * (j + 1) / 2);
      if (k % j == 0) {
        int p = k / j;
        int x = sx[j + p] ^ sx[p];
        if (x < 500) us[x] = 1;
      }
    }
    for (int j = 0;; ++j) {
      if (!us[j]) {
        dp[i] = j;
        break;
      }
    }
    sx[i] = sx[i - 1] ^ dp[i];
  }
  if (dp[n] > 0) {
    int res = 0;
    for (int j = 2; j * (j + 1) <= 2 * n; ++j) {
      int k = n - (j * (j + 1) / 2);
      if (k % j == 0) {
        int p = k / j;
        int x = sx[j + p] ^ sx[p];
        if (x == 0) {
          res = j;
          break;
        }
      }
    }
    printf("%d\n", res);
  } else
    puts("-1");
  return 0;
}
