#include <bits/stdc++.h>
int grundy[200000];
int best[200000];
using namespace std;
int main() {
  for (int i = 0; i < (int)200000; i++) best[i] = -1;
  grundy[1] = 0;
  grundy[2] = 0;
  grundy[3] = 1;
  best[3] = 2;
  for (int i = 4; i < 200000; i++) {
    int j = 2;
    set<int> vec;
    vec.clear();
    while ((j * (j - 1)) / 2 <= i) {
      if ((i - (j * (j - 1) / 2)) % j == 0) {
        int n = 0;
        for (int k = (i - (j * (j - 1)) / 2) / j;
             k < (i - (j * (j - 1)) / 2) / j + j; k++)
          n = n ^ grundy[k];
        vec.insert(n);
        if (n == 0 && (best[i] == -1 || best[i] > j)) best[i] = j;
      }
      j++;
    }
    grundy[i] = 0;
    while (vec.find(grundy[i]) != vec.end()) grundy[i]++;
  }
  int n;
  cin >> n;
  cout << best[n] << endl;
}
