If you're only interested in channels your are also in: use $comchan($nick,0), it gives you the number of channels both you and $nick are in. You can even loop all channels with $comchan($nick,[color:red]N)[/color] with N going from 1 to the number of common channels.

If you really want to include all channels in the count, so also channels you haven't joined: it's impossible. /whois nick will not only be very bandwith expensive for multiple users, it will also be incomplete: private or secret channels will not be shown in the /whois info...
(And as said before: why would you even want to do this?)