For each element of $ S $, count the number of times that he is a member of $ A_i $, $ 1 the i the n $. If this number is $ m $we add 1 to the count. The final count is what we wanted.
The algorithm above takes $ O (tn) $ time if the calculation cost to check the membership is $ O (1) $. It takes $ O (ttn) $ time if the cost in calculation to check the membership is proportional to the size of the set, which is at most $ t $.
So, you can see that the problem is in $ P $. This has nothing to do with this general principle of inclusion – exclusion.