#coding=UTF-8 #まあまあ真面目に解いてみる N=int(input()) ans=0 #逆向きに時間を回してみる while N!=1: rusuban=N%2 #出来るだけたくさん倍増させる方針 N=N//2 N=N+rusuban ans=ans+1 print(ans)