#include <bits/stdc++.h>
using namespace std;
int grundy[100005];
int sum[100005];
int v[100005], k = 0;
bool vis[100005];
vector<int> lo[100005], hi[100005];
int main() {
  int n, mn = 1e9;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int sum = i;
    for (int j = 1; 1; j++) {
      sum += i + j;
      if (sum > n) break;
      lo[sum].push_back(i);
      hi[sum].push_back(i + j);
    }
  }
  for (int i = 1; i <= n; i++) {
    k = 0;
    for (int j = 0; j < lo[i].size(); j++) {
      int g = sum[hi[i][j]] ^ sum[lo[i][j] - 1];
      int m = hi[i][j] - lo[i][j] + 1;
      if (i == n && g == 0) mn = min(mn, m);
      v[k++] = g;
      vis[g] = 1;
    }
    for (int j = 0; 1; j++) {
      if (vis[j]) continue;
      grundy[i] = j;
      break;
    }
    for (int j = 0; j < k; j++) vis[v[j]] = 0;
    sum[i] = sum[i - 1] ^ grundy[i];
  }
  if (grundy[n] == 0)
    printf("-1\n");
  else
    printf("%d\n", mn);
}
