The equation w = 6m+4, relates how a dog's weight varies with age, where m represents its age in months, and the w represents its weight in pounds. How many months before the dog weighed 58 pounds?