import java.util.Scanner; class no47{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); int biscuits = 1; int num = 0; while(true){ if( biscuits == N){ break; } if( biscuits * 2 <= N ){ biscuits *= 2; num++; } else{ if( N - biscuits == 1){ num++; break; } else if( (N - biscuits) % 2 == 0 ){ num++; break; } else{ num += 2; break; } } } System.out.println(num); } }