#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;
const long double EPS = 1e-12;
int dp[100005];
int pre[100005];
int net[100005];
int ans[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)n + 1; i++) {
    dp[i] = 0;
    pre[i] = 0;
    net[i] = 0;
    ans[i] = -1;
  }
  for (int i = (int)2; i < (int)n + 1; i++) {
    for (int j = 2; (2 * i) > j * (j - 1); j++) {
      int k = 2 * i - j * (j - 1);
      if (k % (2 * j) == 0) {
        int d = k / (2 * j);
        int val = pre[j + d - 1] ^ pre[d - 1];
        net[val] = i;
        if (val == 0 && ans[i] == -1) {
          ans[i] = j;
        }
      }
    }
    int mex = 0;
    while (net[mex] == i) mex++;
    dp[i] = mex;
    pre[i] = dp[i] ^ pre[i - 1];
  }
  cout << ans[n] << endl;
  return 0;
}
