#include <bits/stdc++.h>
using namespace std;
int n;
int g[100005];
int sum[100005];
int sg[100005];
bool s[100005][256];
int main() {
  int parts;
  int delta;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 256; j++) {
      if (!s[i][j]) {
        g[i] = j;
        break;
      }
    }
    for (int j = i - 1; (j >= 0) && (sum[j] < n); j--) {
      sum[j] += i;
      sg[j] ^= g[i];
      if (sum[j] <= n) {
        s[sum[j]][sg[j]] = true;
      }
    }
  }
  if (g[n] == 0) {
    cout << -1;
    return 0;
  }
  parts = 1;
  delta = 0;
  while (1) {
    int tg = 0;
    delta += parts;
    parts++;
    if ((n - delta) % parts == 0) {
      int first = (n - delta) / parts;
      for (int i = first; i < first + parts; i++) {
        tg ^= g[i];
      }
      if (tg == 0) {
        cout << parts;
        return 0;
      }
    }
  }
  return 0;
}
