const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    // Write your code here
    line = await readline();
    x = parseInt(line);
    
    if(x<2&&x>=0){
        console.log(x);
    }else{
    if(x < 0){
        x = -x;
    }
    let dp = [];
    dp[0]=0;
    dp[1]=1;
    for(let i=2; i<=x; i++){
        if(i%2==0){
            dp[i] = dp[i/2]+1;
        }else{
            dp[i] = Math.min(dp[i-1], 1+dp[(i+1)/2])+1
        }
    }
    console.log(dp[x]);
    }
}()