Enable different number of recommendations on different pages

Hi! I was wondering is it possible to implement max 4 Related Products recommendations on PDP and max 5 in Cart? How we can do it?