# [Python 2], <s>124</s> 120 bytes

<!-- language-all: lang-python -->

 X,Y=input()
 i=j=s=0
 while i<len(X):
 v=abs(Y[j]-X[i])
 if j+1<len(Y)and v>=abs(Y[j+1]-X[i]):j+=1
 else:s+=v;i+=1
 print s

[Try it online!][TIO-jj3b6d4q]

[Python 2]: https://docs.python.org/2/
[TIO-jj3b6d4q]: https://tio.run/##NY4xT8MwEIXn3q84qUNsxUhNS0sxmK2sLAyJqg5pcqgOkWPZTmh/vXFQGe50790nvWdv4TKYdWyGllSWZbEUldLGjoFx0KpTXq3g56J7Qv3ak2Ell4CTqs@eVcfu9FAe9YkD6i/s8uKPqHhtWpze/pm8uFOyy1UBSL0n6XM1vehZW6dNQB9TONyTPt1IEhbB3dJe0JUanPtBOhuyAQ8f7wfnBjd/z47qb4Al0tVSE6jFYQypvkzWNs0OIivEVjxzwTbiUTxxSHotNkmvxJ7HXw "Python 2 – Try It Online"

Saved 4 bytes by moving to program versus function.

Note that each time around the loop, either `i` is incremented or `j` is incremented. Thus the loop is executed at most `len(X)+len(Y)` times.