Total onto functions from R={a,b,c,d,e} to S={1,2,3,4}:
Using inclusion-exclusion: 45−(14)⋅35+(24)⋅25−(34)⋅15
=1024−4(243)+6(32)−4(1)=1024−972+192−4=240
Now subtract onto functions where f(a)=1. When f(a)=1, we need f:{b,c,d,e}→{1,2,3,4} to be onto (since every element of S must be hit).
But wait — element 1 is already hit by f(a)=1. So {b,c,d,e} must cover {2,3,4} (all of them), and may also map to 1.
Number of such functions = total functions from 4 elements to 4 elements that cover {2,3,4}:
=44−(13)⋅34+(23)⋅24−(33)⋅14
=256−3(81)+3(16)−1=256−243+48−1=60
Onto functions with f(a)=1 = 240−60=180