William travels to school in two different ways. Either he walks to school and takes the bus home, or he takes the bus to school and walks home. In each case his total travelling time is \(40\) minutes. If he were to take the bus both ways, his total travelling time would be \(20\) minutes. How many minutes would it take if he walked both ways?