#include <bits/stdc++.h>
const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
using namespace std;
int N, ans;
const int MAX_N = 1e5;
bool isInt(double x) { return ceil(x) == floor(x); }
int dp[MAX_N + 1];
int grundy(int x) {
  if (x <= 2) return 0;
  if (dp[x] != -1) return dp[x];
  set<int> S;
  for (int k = 2; k < 1000; k++) {
    double m = (double)x / k - (k - 1) / 2.0;
    if (m < 0) break;
    if (isInt(m)) {
      int check = 0;
      for (int i = 0; i < k; i++) {
        check ^= grundy((int)m + i);
      }
      S.insert(check);
      if (x == N && check == 0) ans = min(ans, k);
    }
  }
  int g = 0;
  while (S.count(g)) g++;
  return dp[x] = g;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> N;
  ans = INF;
  cout << (grundy(N) ? ans : -1) << endl;
}
