To count how many different public transport sections there are in a route (e.g 2 busses and 2 trains), you can count how many part IDs in the routes response have a public transport mode (e.g "bus"). Each (non-walking) part ID is a complete, separate public transport section.
Below is an example of what one of these public transport sections will look like in the response: