Anna has a box of 40 candies. She shares some of them equally among 8 friends. After sharing, she has 4 candies left. How many candies did Anna share with her friends?