#include <bits/stdc++.h>
using namespace std;
int g[1000000], n, u[1000000], pref[1000000], cc;
int main() {
  int n;
  cin >> n;
  g[0] = g[1] = g[2] = 0;
  for (int i = 3; i <= n; ++i) {
    cc++;
    for (int j = 2; j * j <= 2 * i; ++j)
      if ((2 * i) % j == 0) {
        int k = j;
        int a1 = ((2 * i) / k - 1 + k) / 2;
        if (a1 - k + 1 > 0 && (2 * a1 - k + 1) * k == 2 * i) {
          u[pref[a1] ^ pref[a1 - k]] = cc;
        }
        k = (2 * i) / j;
        a1 = ((2 * i) / k - 1 + k) / 2;
        if (a1 - k + 1 > 0 && (2 * a1 - k + 1) * k == 2 * i) {
          u[pref[a1] ^ pref[a1 - k]] = cc;
        }
      }
    for (int j = 0;; ++j)
      if (u[j] != cc) {
        g[i] = j;
        break;
      };
    pref[i] = pref[i - 1] ^ g[i];
  }
  if (g[n] == 0)
    puts("-1");
  else {
    int mink = (1 << 30);
    int i = n;
    for (int j = 2; j * j <= 2 * i; ++j)
      if ((2 * i) % j == 0) {
        int k = j;
        int a1 = ((2 * i) / k - 1 + k) / 2;
        if (a1 - k + 1 > 0 && (2 * a1 - k + 1) * k == 2 * i) {
          if ((pref[a1] ^ pref[a1 - k]) == 0) mink = min(mink, k);
        }
        k = (2 * i) / j;
        a1 = ((2 * i) / k - 1 + k) / 2;
        if (a1 - k + 1 > 0 && (2 * a1 - k + 1) * k == 2 * i) {
          if ((pref[a1] ^ pref[a1 - k]) == 0) mink = min(mink, k);
        }
      }
    printf("%d\n", mink);
  }
  return 0;
}
