#include <bits/stdc++.h>
using namespace std;
struct tgame {
  int sg_value;
  int piles_count;
};
int numbers[100000 + 1];
int game_sg_values[100000 + 1];
vector<tgame> games[100000 + 1];
int min(int a, int b) { return a < b ? a : b; }
int calculate_sg_value(vector<tgame> position) {
  for (int i = 0; i < position.size(); i++) {
    numbers[position[i].sg_value] = 1;
  }
  int sg_value = 0;
  while (numbers[sg_value] == 1) {
    sg_value++;
  }
  for (int i = 0; i < position.size(); i++) {
    numbers[position[i].sg_value] = 0;
  }
  return sg_value;
}
int get_min_piles_count(int n) {
  int min_piles_count = games[n][0].piles_count;
  for (int i = 1; i < games[n].size(); i++) {
    if (games[n][i].sg_value == 0)
      min_piles_count = min(min_piles_count, games[n][i].piles_count);
  }
  return min_piles_count;
}
int main(void) {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    game_sg_values[i] = calculate_sg_value(games[i]);
    int sum = i;
    tgame current_game = {game_sg_values[i], 1};
    for (int j = i - 1; j >= 1 && sum + j <= 100000; j--) {
      current_game.sg_value = (current_game.sg_value ^ game_sg_values[j]);
      current_game.piles_count++;
      sum += j;
      games[sum].push_back(current_game);
    }
  }
  cout << (game_sg_values[n] != 0 ? get_min_piles_count(n) : -1) << "\n";
  return 0;
}
