Since the function is surjective, the pre-image of any element is non-empty. Thus, the maximum number of elements in any pre-image of any element is 3. So we break it up into cases:
Case 1 Some element in B has 3 elements in its preimage: There are $\binom{4}{1} = 4$ ways to pick that element. Given that element there are $\binom{6}{3}$ = 20 ways to pick the 3 elements in A as the pre-image. Then there are 3!=6 ways to pick the pre-images of the remaining elements. So this case has counted 4*20*6 such functions.
Case 2 Two elements in B each have 2 elements in its preimage: Arguing similarly in Case 1, we have $\binom{4}{2}$=6 ways to pick these two elements. Given the two elements we have $\binom{6}{2}\binom{4}{2} = 15*6$ ways to pick the pre-images. Then there are 2!=2 ways to pick the pre-image of the remaining elements. So this case has counted 6*15*6*2 such functions.
Now we have exhausted all possibilities, so we just add the numbers together and we are done.