There are red, blue, yellow, and green balls in the bag. 310 of the balls are red, 25 are green and the rest are blue and yellow. There are twice as many blue balls and yellow. There are 17 fewer blue balls than red balls. How many balls are in the bag?