The mathematics of voting, power and sharing