#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > G[100100];
long long grundy[100100];
long long pref[100100];
int cnt[100100];
long long get(int i, int j) {
  long long ans = pref[j];
  if (i) ans ^= pref[i - 1];
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 3; i < 100100; i++) {
    int sq = (sqrt(i) + 10) * 2;
    for (long long j = 2; j <= sq; j++) {
      long long top = j * (j - 1) + 2 * i;
      long long bottom = 1 + j + j - 1;
      if (top % bottom != 0) continue;
      long long h = top / bottom;
      long long l = h - (j - 1);
      if (l <= 0) continue;
      G[i].push_back(make_pair(l, h));
    }
  }
  grundy[1] = grundy[2] = 0;
  pref[1] = pref[2] = 0;
  for (long long i = 3; i < 100100; i++) {
    int sq = sqrt(i) * 2;
    memset(cnt, 0, 4 * sq);
    for (int j = 0; j < G[i].size(); j++) {
      int l = G[i][j].first, h = G[i][j].second;
      int g = get(l, h);
      cnt[g] = 1;
    }
    for (int j = 0; j < sq; j++) {
      if (!cnt[j]) {
        grundy[i] = j;
        break;
      }
    }
    pref[i] = pref[i - 1] ^ grundy[i];
  }
  long long n;
  cin >> n;
  if (grundy[n] == 0) return cout << -1 << endl, 0;
  int ans = 1e9;
  int sq = sqrt(n) * 2;
  for (int i = 0; i < G[n].size(); i++) {
    int l = G[n][i].first, h = G[n][i].second;
    if (get(l, h) == 0) ans = min(ans, h - l + 1);
  }
  cout << ans << endl;
  return 0;
}
