Three cases arise : Last required balls is type P Last required balls is type Q Last required balls is type R
return ( countWays ( p , q , r , 0 ) + countWays ( p , q , r , 1 ) + countWays ( p , q , r , 2 ) ) ; NEW_LINE