Artificial intelligent assistant

Given graph G, find # of paths of lengh 2 I'm solving this graph theory problem: > Let $G$ be a graph on $10$ vertices of degrees $1,1,2,3,3,3,4,4,5,8$. How many paths of length $2$ does $G$ contain? > > (Reminders: A path of length $2$ from vertex $a$ to vertex $b$ is defined as a sequence of two edges $a\text{---}v$ and $v\text{---}b$, where $v$ is some vertex. We do not require $a$ and $b$ to be distinct. If $a$ and $b$ are distinct, then the path $a\text{---}v\text{---}b$ is considered distinct from the path $b\text{---}v\text{---}a$.) I'm not sure where to start. I've tried to list paths, but there is some overlap, and the graph is too big to draw. How should I approach this problem? Thanks.

HINT: Each edge of $G$ contributes two out-and-back paths of length $2$. Each path of length $2$ that is not out-and-back has a vertex at its midpoint that it enters by one edge and leaves by another; thus, each vertex of degree greater than $1$ and each pair of edges incident at that vertex give rise to two more paths of length $2$, one in each direction.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy c6d31afb91a6b9691d3c9c2229aedbb7