Sam baked an equal number of sausage buns and custard buns. During the day, 68 sausage buns were sold. Sam also baked another 27 custard buns to meet a last-minute order. At the end of the day, Sam had baked 6 times as many custard buns as the number of sausage buns remaining. How many sausage buns did Sam bake at first?