#include <bits/stdc++.h>
using namespace std;
int dp[100050];
void prec() {
  dp[0] = dp[1] = dp[2] = 0;
  for (int i = 3; i <= 100000; ++i) {
    bool lose = true;
    vector<int> vec;
    for (int x = 2;; ++x) {
      int sum = (x - 1) * x / 2;
      if (i - sum <= 0) break;
      lose = false;
      if ((i - sum) % x == 0) {
        int xsum = 0;
        int c = (i - sum) / x;
        for (int k = 0; k < x; ++k) {
          xsum ^= dp[c + k];
        }
        vec.push_back(xsum);
      }
    }
    if (lose) {
      dp[i] = 0;
      continue;
    }
    vector<int> a(int(vec.size()) + 1, 0);
    for (int x : vec)
      if (x < int(a.size())) a[x] = 1;
    for (int j = 0; j < int(a.size()); ++j)
      if (!a[j]) {
        dp[i] = j;
        break;
      }
  }
}
int main() {
  prec();
  int n;
  cin >> n;
  if (dp[n] == 0) {
    cout << -1 << endl;
  } else {
    for (int x = 2;; ++x) {
      int sum = (x - 1) * x / 2;
      if ((n - sum) % x == 0) {
        int xsum = 0, c = (n - sum) / x;
        for (int k = 0; k < x; ++k) xsum ^= dp[c + k];
        if (xsum == 0) {
          cout << x << endl;
          exit(0);
        }
      }
    }
  }
  return 0;
}
