this program calculate the distance of each stem of