This is similar to total number of onto functions from m elements to n elements.
$\sum_{k=0}^{n}(-1)^{k}$ $^{n}C_{k}(n-k)^{m}$
Given m=5 and n=3
$\therefore$ The total number of ways in which 5 balls of different color can be distributed among 3 persons so that each person gets at least one ball is
= $3^{5}-$ $^{3}C_{1}(3-1)^{5}+$ $^{3}C_{2}(3-2)^{5}-$ $^{3}C_{3}(3-3)^{5}$
= 243 - 32*3 + 3 - 1
=243 - 93
=150