#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  if (a >= mod) a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    if (res >= mod) res %= mod;
    a = a * a;
    if (a >= mod) a %= mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
vector<int> s[100000 + 5];
int ans[100000 + 5];
int p[100000 + 5];
int ok[100 + 5];
int main() {
  long long from, to, i, n, j, k, n1, n2;
  for (i = 2; i <= 200000; i += 2) {
    for (j = 2; j * j < i; j++) {
      k = i / j;
      if (k * j != i) continue;
      n2 = (j + k - 1) / 2;
      n1 = n2 - j;
      if (n1 >= 0 && j * (n2 + n1 + 1) == i) {
        s[i / 2].push_back(n1 + 1);
      }
    }
  }
  for (i = 1; i <= 100000; i++) {
    k = 0;
    p[i] = -1;
    for (j = 0; j < s[i].size(); j++) {
      from = s[i][j];
      to = sqrt(2 * i + from * ((long long)from - 1));
      ok[ans[from - 1] ^ ans[to]] = i;
      if (p[i] == -1 && ((ans[from - 1] ^ ans[to]) == 0)) p[i] = to - from + 1;
    }
    while (ok[k] == i) k++;
    ans[i] = ans[i - 1] ^ k;
  }
  cin >> n;
  cout << p[n];
  return 0;
}
