#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int N;
int sg[MAXN], mex[MAXN];
int main() {
  int ans;
  int cnt;
  int res;
  int g;
  while (~scanf("%d", &N)) {
    ans = -1;
    cnt = 1;
    for (int i = 0; i <= N; i++) {
      sg[i] = 0;
      mex[i] = 0;
    }
    for (int i = 3; i <= N; i++) {
      for (int m = 2;; m++) {
        res = i - m * (m + 1) / 2;
        if (res < 0) {
          break;
        }
        if (res % m) {
          continue;
        }
        g = 0;
        for (int j = 1; j <= m; j++) {
          g ^= sg[res / m + j];
        }
        if (!g && i == N && ans == -1) {
          ans = m;
          break;
        }
        mex[g] = cnt;
      }
      for (int j = 0;; j++) {
        if (mex[j] != cnt) {
          sg[i] = j;
          cnt++;
          break;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
