Implicit type conversion, bit manipulation and addition (for answer) solution
\n# Code\ncpp []\nclass Solution {\npublic:\n    int minChanges(int n, int k) {\n        int ans = 0;\n        while(n&&k)\n        {\n            ans+=(n&1)^(k
\n# Code\n```cpp []\nclass Solution {\npublic:\n    int minChanges(int n, int k) {\n        int ans = 0;\n        while(n&&k)\n        {\n            ans+=(n&1)^(k&1);\n            if(!(n&1)&&(k&1)) return -1;\n            n>>=1;\n            k>>=1;\n        }\n        if(!n&&k) return -1;\n        while(n)\n        {\n            ans+=n&1;\n            n>>=1;\n        }\n        return ans;\n    }\n};\n```
['C++']