Andrew is renovating his house and needs to manage his inventory of wooden planks. He used 8 planks for his bedroom, 20 planks for his living room, and 11 planks for his kitchen. The guest bedroom required 2 fewer planks than his bedroom, and each of his two hallways required 4 planks. Unfortunately, he ruined 3 planks in each bedroom due to dragging furniture and had to replace them. After completing the renovations, he ended up with 6 leftover planks. How many wooden planks did Andrew buy to start with? Let's think step by step and output the final answer within \boxed{}.
user