#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int f[MAXN], x[MAXN], n, ans;
vector<pair<int, int> > a[MAXN];
priority_queue<int> used;
inline int s(int a1, int n) { return (2 * a1 + n - 1) * n / 2; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 2; s(i, j) <= n; j++) a[s(i, j)].push_back(make_pair(i, j));
  for (int i = 3; i <= n; i++) {
    while (!used.empty()) used.pop();
    for (int k = 0; k < a[i].size(); k++)
      used.push(
          -(x[a[i][k].first + a[i][k].second - 1] ^ x[a[i][k].first - 1]));
    int tmp = -1;
    while (!used.empty()) {
      if (-used.top() != tmp) {
        tmp = -used.top();
        if (f[i] != tmp)
          break;
        else
          f[i]++;
      }
      used.pop();
    }
    x[i] = x[i - 1] ^ f[i];
  }
  if (f[n] == 0)
    ans = -1;
  else {
    ans = n;
    for (int i = 0; i < a[n].size(); i++) {
      int tmp = 0;
      for (int j = a[n][i].first; j < a[n][i].first + a[n][i].second; j++)
        tmp ^= f[j];
      if (tmp == 0) ans = min(ans, a[n][i].second);
    }
  }
  cout << ans;
  return 0;
}
