#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const double EPS = 1e-9;
int n, f[N + 2];
bool isInteger(double x) { return abs(x - round(x)) <= EPS; }
int Solve() {
  f[0] = f[1] = f[2] = 0;
  for (int i = 3; i <= n; ++i) {
    int lim = sqrt(i * 2);
    vector<bool> chk(lim + 1, false);
    for (int j = 2; j <= lim; ++j)
      if (isInteger((double)i / j + (double)j / 2 + 0.5)) {
        int l = (i * 2 / j - j + 1) / 2, r = (i * 2 / j + j - 1) / 2;
        chk[f[r] ^ f[l - 1]] = true;
        if (i == n && (f[r] ^ f[l - 1]) == 0) return j;
      }
    for (int j = 0; j <= lim; ++j)
      if (!chk[j]) {
        f[i] = j;
        break;
      }
    f[i] ^= f[i - 1];
  }
  return -1;
}
int main() {
  scanf("%d", &n);
  printf("%d", Solve());
  return 0;
}
