If 'p' is the given perimeter,
The total number of triangles.
= $$\dfrac{p^2}{48}$$ if p is even.
= $$\dfrac{\left(p+3\right)^2}{48}$$ if p is odd.
The number of scalene triangles:
= $$\dfrac{\left(p-6\right)^2}{48}$$ if p is even.
= $$\dfrac{\left(p-3\right)^2}{48}$$ if p is odd.
In all cases, the resulting value should be rounded to the nearest integer.