#include <bits/stdc++.h>
using namespace std;
int n;
int g, h, r;
vector<vector<int> > a(0);
vector<int> a0(0), b, c, u;
int x, y, z;
long long int f(long long int p) {
  if (p % 4 == 0) return p;
  if (p % 4 == 1) return 1;
  if (p % 4 == 2) return p + 1;
  if (p % 4 == 3) return 0;
}
int main() {
  cin >> n;
  a.push_back(a0);
  for (int j = 1; j <= n; j++) {
    a.push_back(a0);
    for (int i = 2; i * i + i <= 2 * j; i++) {
      if (i % 2 == 0 && 2 * j % i == 0 && j % i != 0 ||
          i % 2 == 1 && j % i == 0)
        a[j].push_back(i);
    }
  }
  b.assign(n + 1, 0);
  c.assign(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (a[i].size() > 0) {
      u.resize(0);
      for (int j = 0; j < a[i].size(); j++) {
        x = a[i][j];
        y = (i - x * (x - 1) / 2) / x;
        u.push_back(c[y - 1] ^ c[x + y - 1]);
      }
      sort(u.begin(), u.end());
      for (int j = 0; j < u.size() && b[i] >= u[j]; j++)
        if (b[i] == u[j]) b[i]++;
    }
    c[i] = b[i] ^ c[i - 1];
  }
  if (b[n] == 0)
    cout << -1;
  else {
    for (int i = 0; i < a[n].size(); i++) {
      x = a[n][i];
      y = (n - x * (x - 1) / 2) / x;
      if ((c[y - 1] ^ c[x + y - 1]) == 0) {
        cout << x;
        return 0;
      }
    }
  }
  return 0;
}
