#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
bool bad( int MOD ) {
int was[MOD];
fill(was, was + MOD, 0);
forn(i, 64) {
int j = (1ULL << i) % MOD;
if (was[j]++)
return 1;
}
return 0;
}
int main() {
int MOD = 1;
while (bad(MOD))
MOD++;
printf("%d\n", MOD);
return 0;
}