#include <bits/stdc++.h>
using namespace std;
const int maxSubState = 447;
bool used[100000 + 1][maxSubState + 1];
int sg[100000 + 1];
int minSplit[100000 + 1];
int main() {
  for (int upper = 1; upper <= 100000; ++upper) {
    for (int i = 0; i < sizeof(used[0]) / sizeof(used[0][0]); ++i) {
      if (!used[upper][i]) {
        sg[upper] = i;
        break;
      }
    }
    int sum = upper;
    int newSg = sg[upper];
    for (int low = upper - 1; low >= 1 && (sum += low) <= 100000; --low) {
      newSg ^= sg[low];
      if (newSg == 0) {
        if (minSplit[sum] == 0)
          minSplit[sum] = upper - low + 1;
        else
          minSplit[sum] = min(minSplit[sum], upper - low + 1);
      }
      if (newSg < sizeof(used[0]) / sizeof(used[0][0])) used[sum][newSg] = true;
    }
  }
  int n;
  while (scanf("%d", &n) == 1) {
    if (sg[n] != 0) {
      printf("%d\n", minSplit[n]);
    } else {
      puts("-1");
    }
  }
}
