Q:

The number of ways to place distinct balls in identical bins

Count the number of ways to place 6 distinct balls in 4 identical bins.

I tried to use “Stirling number” for this problem.
\begin{align}
S(n,k) &= S(n-1,k-1) + kS(n-1,k)  \qquad\text{if}\ 1 < k < n \\
S(n-1,k-1)  &= \binom{n+k-1}{k-1} = \binom{9}{3} = \frac{9!}{3!\cdot 6!} = 84 \\
kS(n-1,k) 4 \binom{n-1}{k} &=  \binom{5}{4} = \frac{5!}{4!} = 5  = 20
\end{align}
$$84 + 20 = 104$$
However, the correct answer is $342$.

A:

The stated answer is too large.  We can partition the number $6$ into at most four parts in the following ways:
\begin{align*}
6 & = 6\\
  & = 5 + 1\\
  & = 4 + 2\\
  & = 4 + 1 + 1\\
  & = 3 + 3\\
  & = 3 + 2 + 1\\
  & = 3 + 1 + 1 + 1\\
  & = 2 + 2 + 2\\
  & = 2 + 2 + 1 + 1
\end{align*}
These partitions correspond to the following distributions.
$6$:  All six balls can be placed in one bin in one way.
$5 + 1$:  Five balls can be placed in one bin and one ball can be placed in a different bin in six ways, depending on which ball is placed in a separate bin.
$4 + 2$:  Four balls can be placed in one bin and two bins can be placed in a different bin in $\binom{6}{4} = 15$ ways, depending on which four balls are placed together.
$4 + 1 + 1$:  Four balls can be placed in one bin and the other two balls can be placed in separate bins in $\binom{6}{4} = 15$ ways, again depending on which four balls are placed together.
$3 + 3$:  Suppose the balls are six different colors, including blue.  There are $\binom{5}{2} = 10$ ways to choose which two balls are placed in the same bin as the blue ball.  The other three balls must be placed in another bin.
$3 + 2 + 1$:  There are $\binom{6}{3}\binom{3}{2}\binom{1}{1} = 60$ ways to distribute the balls to three bins so that one bin receives three balls, another bin receives two balls, and the third bin receives one.
$3 + 1 + 1 + 1$:  There are $\binom{6}{3} = 20$ ways to distribute the balls to four bins so that one bin receives three balls and each of the other bins receives one ball, depending on which three balls are placed together.
$2 + 2 + 2$:  Suppose the balls are different colors.  If we list the balls in alphabetical order, there are five ways to choose which ball is placed in the same bin as the first ball on the list.  That leaves four balls.  There are three ways to pick the color of the ball that is placed in the same bin as the first ball remaining on the list.  The third bin must hold the remaining two balls.  Hence, there are $\binom{5}{1}\binom{3}{1} = 15$ ways to distribute the balls so that two balls each are placed in three of the indistinguishable bins.
$2 + 2 + 1 + 1$:  There are $\binom{6}{2}$ ways to choose which two balls will be placed in a bin by themselves.  That leaves four balls to distribute to the remaining two bins in such a way that each such bin receives two balls.  If we list the remaining balls alphabetically, the color of the ball that is placed in the same bin as the ball with the first color on that list can be chosen in three ways.  Hence, there are $\binom{6}{2}\binom{3}{1} = 45$ ways to distribute the balls so that two bins each receive two balls and two other bins each receive one ball.
That gives a total of $1 + 6 + 15 + 15 + 10 + 60 + 20 + 45 = 187$ ways to distribute six distinct balls to four indistinguishable bins.
In terms of Stirling numbers of the second kind, the above calculations show 
\begin{align*}
S(6, 1) & = 1\\
S(6, 2) & = 6 + 15 + 10 = 31\\
S(6, 3) & = 15 + 60 + 15 = 90\\
S(6, 4) & = 20 + 45 = 65
\end{align*}
Note that $S(6, 1)$ corresponds to the $6$ balls in one bin case; $S(6, 2)$ corresponds to the distributions $5 + 1$, $4 + 2$, and $3 + 3$; $S(6, 3)$ corresponds to the distributions $4 + 1 + 1$, $3 + 2 + 1$, $2 + 2 + 2$; $S(6, 4)$ corresponds to the distributions $3 + 1 + 1 + 1$, $2 + 2 + 1 + 1$.
In total, there are 
$$S(6, 1) + S(6, 2) + S(6, 3) + S(6, 4) = 1 + 31 + 90 + 65 = 187$$
ways to distribute six distinct balls to four indistinguishable bins.

