#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int logn = 17;
const int inf = (int)1e9;
const long long mod = (int)1e9 + 7;
const long long l_inf = (long long)4e12;
const long double pi = acosl(-1.0);
const long double eps = 1e-12;
int n;
int dp[maxn], pref[maxn], best[maxn];
set<int> mex;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(15);
  cout << fixed;
  srand(566);
  cin >> n;
  memset(best, -1, sizeof best);
  for (int i = 0; i <= n; i++) mex.insert(i);
  for (int i = 1; i <= n; i++) {
    vector<int> sum;
    for (int k = 2; k * (k + 1) / 2 <= i; k++) {
      int common = i - k * (k + 1) / 2 + k;
      if (common % k == 0) {
        sum.push_back(pref[common / k + k - 1] ^ pref[common / k - 1]);
        if (sum.back() == 0 && best[i] == -1) best[i] = k;
      }
    }
    for (int s : sum)
      if (s <= n) mex.erase(s);
    dp[i] = *mex.begin();
    for (int s : sum)
      if (s <= n) mex.insert(s);
    pref[i] = dp[i] ^ pref[i - 1];
  }
  cout << best[n];
  return 0;
}
