#include <bits/stdc++.h>
using namespace std;
int num, sg[100010], mex[100010], col = 1, ans = -1;
int main() {
  scanf("%d", &num);
  for (int n = 3; n <= num; n++) {
    for (int m = 2;; m++) {
      int res = n - (m - 1) * m / 2;
      if (res < 0) break;
      if (res % m) continue;
      int g = 0, x = res / m;
      for (int i = 0; i < m; i++) g ^= sg[x + i];
      if (!g && num == n && ans < 0) {
        ans = m;
        break;
      }
      mex[g] = col;
    }
    for (int j = 0;; j++)
      if (mex[j] != col) {
        sg[n] = j;
        ++col;
        break;
      }
  }
  printf("%d", ans);
}
