TITLE: Permutations with global limited repetition
QUESTION [5 upvotes]: What is the number of permutations of $m$ objects in $n$ spaces such that there are exactly $l$ repetitions in the permutation?
for example,
if $m = 5, n = 7, l = 4$

then $$a_1, a_1, a_1, a_3, a_3, a_4,a_4$$
is a legal sequence (4 repetitions, $a_1$ twice, $a_3$ once and $a_4$ once) but

$$a_1, a_2, a_3, a_1, a_3, a_5, a_3$$ is not (only 3 repetitions).
and neither is 
$$a_1,a_1,a_1,a_1,a_1,a_1,a_1$$ legal.
The main difference of this problem from other posts such as
Calculating number of permutations given N repeats allowed
is that my number of repeats is global, i.e I require that the number of repetitions of all objects together is exactly l.

REPLY [3 votes]: You can pick the elements to be in the sequence that are going to be repeated(say $k$ of them) and then consider the repetitions by constructing a sequence $x_i=\text{# times object i repeats},$ so that
$$\sum _{i=1}^kx_i=l,\, x_i\geq 1.$$
Notice that if we call $k$ the ones that are going to be repeated, then $n-(l+k)$ are non repeated elements.
So your expression is
$$\sum _{k=0}^m\binom{m}{k}\binom{m-k}{n-(l+k)}\sum _{x_1+\cdots +x_k=l}\binom{n}{\underbrace{1,\cdots ,1}_{n-(l+k)},x_1+1,\cdots ,x_k+1}.$$
Now, if this can be expressed in easier terms seems a problem for generating functions, the problem being multivariate by nature.