A group of friends decides to buy a large pizza to share. If the pizza is cut into 8 equal slices, there are 3 slices left over after each friend has taken an equal number of slices. If the pizza is cut into 5 equal slices, there are 2 slices left over after each friend has taken an equal number of slices. If the pizza is cut into 6 equal slices, there are 4 slices left over after each friend has taken an equal number of slices. What is the smallest number of slices the pizza could have had? Let's think step by step and output the final answer within \boxed{}.
user