It's quite simple. First, add 5cm to the progress of the insect, counting it as 1 second. Then subtract 2cm because it falls over the next second, thus taking another second. Then finally, plus 5cm, making it 3 seconds. It's not 4 seconds because at 3 seconds it had already reached the top.
If I didn't clear everything or messed up, please comment.