The algorithm to do it is this:
1. set a minimum distance, to take into account only distance above (so not to count random jumping of the GPS reading)
2. set a start point coordinates
3. check every GPS reading if the distance to the start point is greater than the minimum. if no - do nothing, if yes - add the distance to an accumulator, and set the current position as the start point.
Bear in mind that it will not count movements within the minimum range.