用toBinaryString转成二进制字符串,挨个比较就行了:

import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), n = sc.nextInt();
        String a = Integer.toBinaryString(m);
        String b = Integer.toBinaryString(n);
        while(a.length() < b.length()) a = "0" + a;
        while(b.length() < a.length()) b = "0" + b;
        int i = 0, r = 0;
        while(i < a.length()){
            if(a.charAt(i) != b.charAt(i)) r++;
            i++;
        }
        System.out.println(r);
    }
}