#include using namespace std; typedef long long ll; #define rep(i,n) for(i=0;i>i&1) ++ret; return ret; } int ab(int p){ return (p>0)?p:-p; } int main(int argc, char const *argv[]) { int i,j; int n; cin >>n; int dp[10001]; rep(i,10001) dp[i]=INF; dp[1]=1; queue que; que.push(1); while(!que.empty()){ int v=que.front(); que.pop(); int t=ch(v); if(v-t>=1 && dp[v-t]>dp[v]+1){ dp[v-t]=dp[v]+1; que.push(v-t); } if(v+t<=n && dp[v+t]>dp[v]+1){ dp[v+t]=dp[v]+1; que.push(v+t); } } int ans=dp[n]; if(ans==INF) ans=-1; std::cout << ans << std::endl; return 0; }