Fixed an off by one error for finding the dynamic programming length