After pondering over the question, I believe there is critical information missing. Based on the fact that David went on a diet and "regained" 5 pounds, this question is not possible to answer. The amount of weight that David lost during the diet is needed.
Working backwards 177-5 = 172. Then x-y = 172. x being his original weight plus 17, and y being how much weight he lost on his diet. Since we do not know y, we can't solve for x. Since we can't find x, we can't subtract the 17 pounds he gained to find his original weight.
I'm left wondering if the question meant to state that David gained 7 pounds and during his diet gained 5 more pounds with an ending weight of 177 pounds? Then his original weight would have been 155 pounds.
I pressume that David went on a diet and the result is the increase weights measured in two spells.David first gains 17 pounds and then again gains 5 pounds. Thus after the two gains he weighs 17+5 =22 pounds more than his original weight. The resulting weight now is 177 pounds. So if we remove the 22 pounds he gained over winter and subsequently from his current weight ,177 pounds, we get 177-22= 155 pounds. The problem is just that simple, and we should remember there is nothing to read between the lines.