assuming @cats statment that "Collisions probably means the number of times you put a ball into an already occupied bin"
you can approach this by describing steps of the process and thinking about graph of states.
like: if while counting $c$ collisions so far and having $i$ balls left there are $k$ empty bins left then with probability $p={1 \over k}$ you move to the state "$i-1$ balls ; $k-1$ empty bins; $c$ collisions" and with probability $1-p$ you move to state "$i-1$ balls; $k$ empty bins; $c+1$ collisions".
In short:
Let $S(c,i,k)$ be state described above, the state graph looks like this:
$S(0,N,M)$ - start state
$S(c,0,k)$ - end stats (dla dowolnych $c,k$)
and the edges are:
$S(c,i,k)\begin{matrix}\overset{1 \over k}{\rightarrow} S(c,i-1,k-1)\\ \overset{k-1 \over k}{\rightarrow}S(c+1,i-1,k)\end{matrix} for\, i>0$
now Lets define $p_{cik}$ as probability of reaching state $S(c,i,k)$ and variable $\Bbb X$ which will be a number of collisions.
If we ask "from what state can i move into state $S(c,i-i,k-1)$", the answer will be "We where in $S(c,i,k)$ and we hit an empty bin or we where in $S(c-1,i,k-1)$ and we made a collision"
That gives us a recursive function:
$$p_{c\,i-1\,k-1}={1 \over k}p_{c-1\,i\,k}+{k-1 \over k}p_{c-1\,i\,k-1}$$
And additionally we can say:
$$p_{cik}=0\,for\,\begin{matrix}i \notin \{0,\dots,N\}\\ k \notin \{0,\dots,M\}\end{matrix}$$
since those are not possible
and that
$$p_{0NM}=1$$
that is enough to calculate $p_{cik}$ for $(i,k) \in \{0,\dots,N\} \times \{0,\dots,M\}$
Now we can say
$$P(\Bbb X=x)=\sum_{c_n,i,k} p_{c_nik}$$
where $0\le i \le N$ , $0\le k \le M$ , $\sum_nc_n=x$
Such model could be implemented in any programing language.