#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int tmp;
int dp[MAXN];
int gao(int n, int &ans) {
  ans = -1;
  if (dp[n] != -1) {
    return dp[n];
  }
  bool mark[MAXN] = {0};
  for (int i = 1; i * i <= 2 * n; ++i) {
    if (2 * n % i == 0) {
      int x = i, y = 2 * n / i;
      if ((x + y) & 1) {
        if (x > y) {
          swap(x, y);
        }
        int b = (x + y - 1) / 2;
        int a = y - b;
        if (a == b) {
          continue;
        }
        int sg = 0;
        for (int j = a; j <= b; ++j) {
          sg ^= gao(j, tmp);
        }
        if (sg == 0 && (ans == -1 || ans > x)) {
          ans = x;
        }
        mark[sg] = true;
      }
    }
  }
  for (int i = 0;; ++i) {
    if (!mark[i]) {
      return dp[n] = i;
    }
  }
}
int main() {
  int n;
  memset(dp, -1, sizeof(dp));
  while (cin >> n) {
    int ans;
    gao(n, ans);
    cout << ans << endl;
  }
  return 0;
}
