Finding the length of a ladder