A gardener plants flowers in a garden bed. The number of tulips he plants is three times the number of daffodils. He also plants 5 fewer roses than tulips. If the total number of flowers planted is 58, how many of each type of flower did the gardener plant? Let's think step by step and output the final answer within \boxed{}.
user