#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10, LOG = 26, M = 1e3 + 5, INF = 1e9 + 10, sn = 320;
int gru[N], sm[N], v[N], k = 0;
bool vis[N];
vector<int> lo[N], hi[N];
int main() {
  int n, mn = INF;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int sm = i;
    for (int j = 1;; j++) {
      sm += i + j;
      if (sm > n) break;
      lo[sm].push_back(i);
      hi[sm].push_back(i + j);
    }
  }
  for (int i = 1; i <= n; i++, k = 0) {
    for (int j = 0; j < lo[i].size(); j++) {
      int g = sm[hi[i][j]] ^ sm[lo[i][j] - 1], 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;; j++) {
      if (vis[j]) continue;
      gru[i] = j;
      break;
    }
    for (int j = 0; j < k; j++) vis[v[j]] = 0;
    sm[i] = sm[i - 1] ^ gru[i];
  }
  if (gru[n] == 0)
    cout << "-1\n";
  else
    cout << mn << '\n';
}
