56
 1
 46
 63478
 7578
 56056
 78
 66873
 8149
 35708
 81207
 41385
 37317
 74424
 67817
 684
 15
 96992
 38798
 19715
 627
 39509
 45899
 31893
 1515
 33
 95298
 27443
 60879
 99
 34378
 57113
 36655
 63359
 873
 67341
 100000
 42863
 35
 250
 573
 23
 871
 15748
 92763
 9564
 42602
 38
 42237
 70878
 93764
 303

-1
 -1
 4
 -1
 3
 -1
 4
 2
 2
 -1
 6
 15
 -1
 21
 73
 -1
 2
 -1
 76
 -1
 2
 -1
 -1
 3
 2
 2
 4
 2
 2
 2
 -1
 2
 -1
 34
 18
 2
 -1
 -1
 -1
 5
 3
 -1
 -1
 8
 22
 3
 17
 -1
 18
 -1
 -1
 2

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((x) <= (i) && (i) <= (y))
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof(x))
#define mem1(x)                 memset(x, -1, sizeof(x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>,
      rb_tree_tag,
      tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k


const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const int INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void solve(int testcase)
{
	int n;
	cin >> n;

	int dp[n + 1];
	dp[0] = 0;

	for (int i = 1; i <= n; ++i) {
		int x = sqrt(i) + 10;
		bool mex[x] = {};
		for (int j = 2; 2 * i / j - j + 1 > 0; ++j) {
			if ((2 * i) % j == 0) {
				int a = 2 * i / j - j + 1;
				if (a % 2 == 0) {
					a /= 2;
					mex[dp[a + j - 1] ^ dp[a - 1]] = 1;
					if ((dp[a + j - 1] ^ dp[a - 1]) == 0 && i == n) {
						cout << j;
						return;
					}
				}
			}
		}
		for (int j = 0; j < x; ++j) {
			if (!mex[j]) {
				dp[i] = j;
				break;
			}
		}
	}

	cout << -1;

	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	rlimit stack_size;
	if (getrlimit(RLIMIT_STACK, &stack_size)) { return 1; }
	// stack_size.rlim_cur = stack_size.rlim_max;
	if (setrlimit(RLIMIT_STACK, &stack_size)) { return 2; }
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	// cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		solve(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}