#include <bits/stdc++.h>
using namespace std;
int e[2200000];
int dp[120000];
bool can[120000];
vector<pair<int, int> > v[120000];
void pre() {
  int i;
  memset(e, -1, sizeof(e));
  for (i = 0; i <= 1000; i++) {
    e[i * (i + 1)] = i;
  }
  memset(dp, -1, sizeof(dp));
  int j, s1, s2;
  for (i = 3; i <= 100000; i++) {
    int t = 2 * i;
    for (j = 1; j * j <= t; j++) {
      if (t % j) continue;
      int x = j, y = t / j;
      if ((x + y - 1) % 2) continue;
      int s2 = (x + y - 1) / 2;
      if (s2 - x < 0) continue;
      s1 = s2 - x;
      s1++;
      if (s1 == s2) continue;
      v[i].push_back(make_pair(s1, s2));
    }
  }
}
int ans = -1, d;
void u(int &x, int y) {
  if (x == -1) x = y;
  x = min(x, y);
}
int vis[120000], cas;
int getdp(int x) {
  if (dp[x] != -1) return dp[x];
  int i, l = -1, r = -1, j;
  cas++;
  for (i = 0; i < v[x].size(); i++) {
    l = v[x][i].first, r = v[x][i].second;
    int t = 0;
    for (j = l; j <= r; j++) {
      t ^= getdp(j);
    }
    vis[t] = cas;
    if (!t) {
      if (x == d) {
        u(ans, r - l + 1);
      }
    }
  }
  for (i = 0;; i++)
    if (vis[i] < cas) break;
  return dp[x] = i;
}
int main() {
  int i, j, k;
  pre();
  scanf("%d", &d);
  cas = 0;
  for (i = 1; i <= 100000; i++) getdp(i);
  printf("%d\n", ans);
  return 0;
}
