#include <bits/stdc++.h>
using namespace std;
int g[100005];
int ans;
int n;
int f(int x, int k) {
  int a = x / k + 1 - k;
  if (k < 2 || a < 1 || (a & 1)) {
    return 0;
  }
  return a >> 1;
}
void solve() {
  scanf("%d", &n);
  ans = n;
  vector<int> vv;
  for (int i = 1; i <= n; ++i) {
    vv.clear();
    for (int k = 1, x = (i << 1); k * k <= x; ++k) {
      if (x % k == 0) {
        {
          int a = f(x, k);
          if (a) {
            int v = 0;
            for (int p = 0; p < k; ++p) {
              v ^= g[a + p];
            }
            if (i == n && v == 0) {
              ans = min(ans, k);
            }
            vv.push_back(v);
          }
        }
        {
          int a = f(x, x / k);
          if (a) {
            int v = 0;
            for (int p = 0; p < k; ++p) {
              v ^= g[a + p];
            }
            if (i == n && v == 0) {
              ans = min(ans, k);
            }
            vv.push_back(v);
          }
        }
      }
    }
    sort((vv).begin(), (vv).end());
    vv.resize(unique((vv).begin(), (vv).end()) - vv.begin());
    int cur = 0;
    for (auto it : vv) {
      if (it != cur) {
        break;
      }
      cur = it + 1;
    }
    g[i] = cur;
  }
  if (ans == n) {
    ans = -1;
  }
  printf("%d\n", ans);
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
