#include <bits/stdc++.h>
int diru[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dirv[] = {-1, 0, 1, -1, 1, -1, 0, 1};
using namespace std;
template <class T>
T sq(T n) {
  return n * n;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
bool inside(T a, T b, T c) {
  return a <= b && b <= c;
}
template <class T>
void setmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void setmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
T power(T N, T P) {
  return (P == 0) ? 1 : N * power(N, P - 1);
}
int dp[100010];
int dp2[100010];
vector<pair<int, int> > pre[100010];
void init() {
  int i, j;
  for (i = 1; i < 100001; i++) {
    int tot = i;
    for (j = i + 1; j < 100001; j++) {
      tot += j;
      if (tot > 100000) break;
      pre[tot].push_back(make_pair(i, j));
    }
  }
  for (i = 1; i < 100001; i++) {
    set<int> s;
    for (j = 0; j < ((int)pre[i].size()); j++) {
      s.insert(dp2[pre[i][j].second] ^ dp2[pre[i][j].first - 1]);
    }
    int ret = 0;
    while (s.find(ret) != s.end()) ret++;
    dp[i] = ret;
    dp2[i] = dp2[i - 1] ^ dp[i];
  }
}
int solve(int n) {
  if (dp[n] == 0) return -1;
  int ret = (1 << 29);
  int i = n, j;
  for (j = 0; j < ((int)pre[i].size()); j++) {
    if ((dp2[pre[i][j].second] ^ dp2[pre[i][j].first - 1]) == 0)
      ret = min(ret, pre[i][j].second - pre[i][j].first + 1);
  }
  return ret;
}
int main() {
  int n, T, t = 1, m, i, j, k;
  init();
  while (scanf("%d", &n) == 1) {
    printf("%d\n", solve(n));
  }
  return 0;
}
