In class A: the first bit is 0
the first address = 00000000->0
the last address=01111111->127
so the total address are 2^7=128
but 0.0.0.0 is used requesting ip , and 127.*.*.* is used for loop back address so (2^7)-2
in class B:the first two bits are 10
so the total network id's possible are: 2^(16-2) = 2^14