#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int dp[MAX], sum[MAX], tmp[MAX];
int m_min[MAX];
void ready() {
  memset(dp, 0, sizeof(dp));
  memset(tmp, 0, sizeof(tmp));
  memset(m_min, 0, sizeof(m_min));
  sum[0] = sum[1] = sum[2] = 0;
  int ans = 0;
  for (int i = 3; i < MAX; i++) {
    for (int j = 2;; j++) {
      if ((j + 1) * j / 2 > i) break;
      int left = i - (j + 1) * j / 2;
      if (left % j) continue;
      int x = left / j;
      tmp[sum[j + x] ^ sum[x]] = i;
      if (m_min[i] == 0 && (sum[j + x] ^ sum[x]) == 0) m_min[i] = j;
    }
    while (tmp[dp[i]] == i) dp[i]++;
    sum[i] = sum[i - 1] ^ dp[i];
  }
}
int main() {
  ready();
  int n;
  scanf("%d", &n);
  if (dp[n] == 0)
    printf("-1");
  else
    printf("%d", m_min[n]);
}
