There were all sparrows but six' means that six birds were not sparrows but only pigeons and ducks. Similarly, number of sparrows + number of ducks = 6 and number of sparrows + number of pigeons = 6. This is possible when there are 3 sparrows, 3 pigeons and 3 ducks, that is, 9 birds in all.