I would like to count the number $N_{p,n}$ of $p$-tuple $(j_1,\ldots,j_p)$ such that for some $n\le 3p$ $$ j_1+\ldots +j_p = n \text{ and } 0\le j_i\le 3 \;\;\forall i\in \{1,\ldots,p\} $$
I tried some examples:
$N_{1,n}=3$... but I can't get a general picture
Number of such $p$-tuples= Coefficient of $x^n$ in $(1+x+x^2+x^3)^p$ with $|x|<1.$
$(1+x+x^2+x^3)^p=\left(\frac{1-x^4}{1-x}\right)^p=(1-x^4)^p(1-x)^{-p}=(1-x^4)^p(\sum_{k=0}^\infty(-1)^k {-p\choose k}x^k).$
So, Number of such $p$-tuples $=\sum_{l : 4l\leq n} (-1)^l(-1)^{n-4l}{p\choose l}{-p\choose n-4l}.$
Here I followed the definition ${x\choose k}=\frac{x(x-1)\ldots(x-k+1)}{k!}.$