For last it is 500 combination ...may be help you
rosen chapter 6 , .. you will get all open and closed form of generating function ...
https://gateoverflow.in/85604/generalized-permutation-and-combination for more clearification
Gatecse