I believe that you are looking for the following
Proposition:
Let $n\geq m>0$ be natural numbers. Then the number of surjections from $\{1,\dots,n\}$ to $\{1,\dots,m\}$ equals
$$\sum_{k=0}^m(-1)^k {m\choose k} (m-k)^n.$$
Proof: For $1\leq i \leq m$, let $B_i:=\left\{f:[n]\to [m]\backslash\{i\}\right\}$, where $[N]:=\{1,\dots,N\}$.
Then the number $S$ of surjections from $[n]$ to $[m]$ is given by the cardinality of
$$\left(B_1 \cup \dots \cup B_m\right)^C,$$
i.e. the complement of $B_1 \cup \dots \cup B_m$ in the set of all maps from $[n]$ to $[m]$.
Hence
$$S=\#\left(B_1 \cup \dots \cup B_m\right)^C=m^n-\#\left(B_1 \cup \dots \cup B_m\right),$$
where we used that the number of maps from $[n]$ to $[m]$ equals $m^n$.
Next, using the principal of inclusion-exclusion, we can replace $\#\left(B_1 \cup \dots \cup B_m\right)$ by
$$\sum_{k=1}^m(-1)^{k-1}\sum_{1\leq i_1<i_2<\dots<i_k\leq m}\#\bigcap_{l=1}^k B_{i_l}=-\sum_{k=1}^m(-1)^k\sum_{1\leq i_1<i_2<\dots<i_k\leq m}(m-k)^n.$$
This leaves us with
$$S=m^n+\sum_{k=1}^m(-1)^k\sum_{1\leq i_1<i_2<\dots<i_k\leq m}(m-k)^n.$$
Lastly, $m^n$ can be taken into the first sum, and the second sum just adds up $m\choose k$ times the term $(m-k)^n$, hence the simplification
$$S=\sum_{k=0}^m(-1)^k {m\choose k} (m-k)^n.$$
For you, it suffices to replace $n$ by $7$ and $m$ by $5$ in the Proposition's formula.