#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
const double error = 1e-10;
const double PI = acos(-1);
inline long long int MOD(long long int x, long long int m = mod) {
  long long int y = x % m;
  return (y >= 0) ? y : y + m;
}
const int inf = INT_MAX;
const long long int infl = LLONG_MAX;
const int nmax = 1e5 + 3;
int grundy[nmax], best[nmax];
vector<int> reach[nmax];
void dp() {
  for (int i = 1; i < nmax; i++) {
    sort(reach[i].begin(), reach[i].end());
    int j, k;
    for (k = 0, j = 0; k < nmax; k++) {
      while (j < reach[i].size()) {
        if (reach[i][j] >= k) break;
        j++;
      }
      if (reach[i].size() == j || reach[i][j] > k) break;
    }
    grundy[i] = k;
    reach[i].clear();
    int sum = 0, xorval = 0;
    for (int j = i; j > 0 && sum < nmax; j--) {
      sum += j;
      if (sum >= nmax) continue;
      xorval ^= grundy[j];
      reach[sum].push_back(xorval);
      if (xorval == 0) best[sum] = i - j + 1;
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  dp();
  if (grundy[n] == 0)
    printf("-1");
  else
    printf("%d", best[n]);
}
