#include <bits/stdc++.h>
using namespace std;
int coe[100000];
int nimber[100000 + 1];
int min_piles[100000 + 1];
int pv[1000];
int main() {
  int n;
  cin >> n;
  int i, j, k;
  int sum = 0;
  int start, end;
  for (i = 1; coe[i] <= 100000; i++) {
    sum += i;
    coe[i + 1] = sum;
  }
  nimber[1] = 0;
  nimber[2] = 0;
  for (i = 3; i <= 100000; i++) {
    for (j = 0; j < 1000; j++) {
      pv[j] = 0;
    }
    for (j = 2; coe[j] + j <= i; j++) {
      int r = i - coe[j];
      if (r % j == 0) {
        start = r / j;
        end = start + j;
        int v = 0;
        for (k = start; k < end; k++) {
          v = v ^ nimber[k];
        }
        pv[v] = 1;
        if (!v) {
          if (min_piles[i] == 0) min_piles[i] = j;
          if (j < min_piles[i]) {
            min_piles[i] = j;
          }
        }
      }
    }
    for (j = 0; j <= 100000; j++) {
      if (pv[j] == 0) {
        nimber[i] = j;
        break;
      }
    }
  }
  int ans = (nimber[n]) ? min_piles[n] : -1;
  cout << ans << endl;
  return 0;
}
