I'll describe an extension of @Raphael's answer for arbitrary trees. It's probably not relevant for OP, but it might be for someone else.
The basic idea is the same. We use dynamic programming and our state is $dp[x][y]$ = optimal cost for acquiring a $y$-edge connected subtree rooted in node $x$. As Raphael stated, for binary trees, it's as simple as iterating over how many edges we take from each subtree:
Edit: These formulas don't account for adding the node-son edges to the answer and possibly other details. The heart of the solution lies in the conceptual approach and is not affected by this.
$dp[x][y] = max(dp[son[x][0]][i] + dp[son[x][1]][y - i], i = 0..y)$
Now, it would seem that if the degree were limited by three, we should iterate over how much we take from each of the first two subtrees. But we don't. Consider the exact same recurrence as a above, with a notational twist.
$dpFirstTwo[x][y] = max(dp[son[x][0]][i] + dp[son[x][1]][y - i], i = 0..y)$
Ok so we've just ignored the third son. To take care of him, we'll do this again, but iterating over how many edges we take from the first two sons combined, which we have stored in $dpFirstTwo$.
So we have:
$dp[x][y] = max(dpFirstTwo[x][i] + dp[son[x][2]][y - i], i = 0..y)$
This can be easily extended. The main idea is that before processing the $i$-th son, we already have computed a, let's call it, $dpFirst(i-1)sons[x][y]$ table. And we can combine these results with the $i$-th son's contribution in an identical manner with the binary tree case.
Also, I claim that the complexity can come down to $O(N ^ 2)$ overall, where $N$ is the vertex count. This is better than $O(N K ^ 2)$ for most $K$'s. To achieve this complexity, you just have to take care and not try to compute or iterate over states that cannot exist: A subtree with $5$ nodes cannot produce a $7$ edge subtree. If you do this, for each node you will do work proportional to the sum of pairwise products of sons subtrees sizes. Because these, in total, amount to all the pairs of nodes in the tree, we obtain the desired $O(N ^ 2)$ bound.
An implementation can be tested here:
http://main.edu.pl/en/archive/pa/2007/bar. (You need $O(N ^ 2)$ time for 100 points)