#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int dp[n];
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;
  vector<int> mark(n + 5, 0);
  for (int i = 3; i < n; i++) {
    int turn = 2;
    while (((turn + 1) * turn) / 2 <= i) {
      if ((i - (((turn - 1) * turn) / 2)) % turn == 0) {
        int ans = 0;
        int val = (i - (((turn - 1) * turn) / 2)) / turn;
        for (int j = 0; j < turn; j++) {
          ans = ans ^ dp[val];
          val++;
        }
        mark[ans] = i;
      }
      turn++;
    }
    for (int j = 0; j < n + 5; j++) {
      if (mark[j] != i) {
        dp[i] = j;
        break;
      }
    }
  }
  int final = -1;
  int turn = 2;
  while (((turn + 1) * turn) / 2 <= n) {
    if ((n - (((turn - 1) * turn) / 2)) % turn == 0) {
      int ans = 0;
      int val = (n - (((turn - 1) * turn) / 2)) / turn;
      for (int j = 0; j < turn; j++) {
        ans = ans ^ dp[val];
        val++;
      }
      if (ans == 0) {
        final = turn;
        break;
      }
    }
    turn++;
  }
  cout << final;
}
