Each instruction has 12 bits- 4 for opcode, next 4 first address and final 4 second address.
We have 12 double operand instructions which leaves 4 combinations of first 4 bits free. We have 4 bits left. Let them be
We need to identify 1-operand and 0-operand instructions with these 4 bits as told in the question. i.e., we cannot use any of these 4 for both one operand as well as 0 operand (which we do when using extended opcode technique).
Now, we need 24 single operand instructions. If we take 1100 for single operand instruction using the next 4 bits (we can use the first address field for instruction as we need only 1 address here) we can get 16 instructions. But we need 24 instructions which require us to use "1101" also. This gives us 16+16 = 32 possible instructions of which we use only 24.
Now, we have 1110 and 1111 for 0 operand instructions. Each of these allows $2^8 = 256$ 0 operand instructions and thus we get $512$ such instructions possible.