Sarah bakes some cookies to distribute among her friends. She gives 8 cookies to her friend Emma and three times as many to her friend Mike. After she has given away all the cookies to Emma and Mike, she has 4 cookies left for herself. How many cookies did Sarah bake in total? Let's think step by step and output the final answer within \boxed{}.
user