A football team gained 12 yards on one play, lost 40 yards on another, and gained 34 yards on the last play of the first half. They had already gained 345 already during the half. What was the total yardage gain for the first half?