#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000;
int sp[MAX + 1];
int xo[MAX + 1];
vector<pair<int, int> > v[MAX + 1];
int main() {
  for (int i = 1; i <= MAX / 2; i++) {
    for (int j = 2; j * (2 * i + j - 1) <= 2 * MAX; j++) {
      int n = j * (2 * i + j - 1) / 2;
      v[n].push_back(make_pair(i, j));
    }
  }
  for (int i = 3; i <= MAX; i++) {
    vector<int> temp(1);
    temp[0] = -1;
    for (int j = 0; j < v[i].size(); j++) {
      int start = v[i][j].first;
      int end = start + v[i][j].second - 1;
      temp.push_back(xo[end] ^ xo[start - 1]);
    }
    sort(temp.begin(), temp.end());
    int k = 1;
    for (; k < temp.size(); k++) {
      if (temp[k] == temp[k - 1]) continue;
      if (temp[k] != temp[k - 1] + 1) break;
    }
    sp[i] = 1 + temp[k - 1];
    xo[i] = sp[i] ^ xo[i - 1];
  }
  int N;
  cin >> N;
  if (!sp[N]) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = v[N].size() - 1; i >= 0; i--) {
    int start = v[N][i].first;
    int end = v[N][i].second - 1 + start;
    if (!(xo[end] ^ xo[start - 1])) {
      cout << v[N][i].second << endl;
      return 0;
    }
  }
}
