How to get a real market cap?

I can import from Yahoo shares outstanding, but this information is not sufficient to calculate a market cap, as MC represents the price of all company shares, not only the type I am querying about.
Example: BRK-B has 1.35B so. Current price is $192, which gives us 259B. But the real market cap is 475B, which accounts for BRK-A too.
I realize that the "proportion" information is hard to get, but perhaps AmiBroker can calculate and store at least approximate value during fundamentals import (as market cap is exposed via API)?