Suppose $g(z) = \sum_{x=1}^N z^x \mathbb{P}(X=x)$ is the probability generating function of $x$. Then, assuming i.i.d. $x_j$, the probability generating function for the sum of $S_k = \sum_{j=1}^k x_j$ for a fixed is simply the power:
$$
g_{S_k}(z) = g(z)^k
$$
The probability you seek:
$$
\mathbb{P}(K=i | S=m) = [z]^m g(z)^i = \binom{i}{j_1,j_2,\ldots,j_N} \mathbf{1}_{j_1+2j_2+\ldots+N j_N = m} \prod_{s=1}^N \left(\mathbb{P}(X=s)\right)^{j_s}
$$
Example:
Let's assume that $X$ follows $\mathrm{Bin}(N-1,p)$ distribution shifted by +1. Then $g(z) = z (1-p+p z)^{n-1}$. Therefore $g(z)^i = z^i \left( 1-p+ p z\right)^{i (n-1)}$. In this case:
$$
\mathbb{P}(K=i|S=m) = \binom{i(n-1)}{m-i} p^{m-i} (1-p)^{ i n - m} \mathbb{1}_{n \cdot i \ge m \ge i}
$$