public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int n = input.nextInt();
		String binN = Integer.toBinaryString(n);                          		 
		
		int first = 0;
		int second = 1;														   
		int count = 0;
		
		for (int i = 0; i < binN.length() - 1; i++) {
			int nRightFirst = n >> first;
			int bitFirst = nRightFirst & 1;
			
			int nRightSecond = n >> second;
			int bitSecond = nRightSecond & 1;
			
			if (bitFirst == bitSecond) {
				count++;
			}
			first++;
			second++;
			bitFirst = 0;
			bitSecond = 0;
		}
		System.out.println(count);		
	}