There are $1000$ students in a school. Every student has exactly $4$ friends. A group of three students $\{A,B,C\}$ is said to be a friendly triplet if any two students in the group are friends. Determine the maximal possible number of friendly triplets.

Let's think step by step and output the final answer within \boxed{}.
user