#include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template ostream& operator<<(ostream &os, const pair &p) { return os << '(' << p.first << ", " << p.second << ')'; } template::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector vi; typedef vector vvi; typedef pair pi; const int mxN = 1e5+1, oo = 1e9; int main() { int N; cin >> N; // remove trailing zeroes // do times a number + 1 // need to make number of bits less. // it's possible in log(n) moves, have only few choices? // always do towards that. // multiplication by 3 could cancel a lot... // 6 do towards that 3 and then 2 left. // multiplication is so chaotic! // want to get (2^k-1)/something = my number // (2^k - 1)(2^k+1) // can do +1 anyway, gives a new bound. // want to get 2^b - 2^a -1. A lot of freedom... // how to get there? 100000000 // how to get there? if(1<<__lg(N)==N) { cout << "1\n"; } else { int ans = 3; // shift then multiply to get 2-power - 1 + 1 if(N%2==1) ans--; cout << ans << '\n'; } }