If the IP address is a.b.c.d . Then, a,b and first 4 bits of c(128+64+32+16=240) are masked and used for network address.So remaining (8-4)=4 bits of c and (8-0) =8 bits of d can be used for connecting hosts.
$\therefore$ Total number of addresses possible with (4+8)=12 bits is $ 2^{4}\times2^{8} =2^{12}$ addresses.
No. of hosts that can be connected=$2^{12} -2$ ........($\because$ First and last addresses are reserved for network and brodcasting,so we subtract 2)