Weird Subtraction

You are given two integers n and m. You have to subtract m from n until n becomes less than or equal to m. See the procedure below.


This is a companion discussion topic for the original entry at https://toph.co/p/weird-subtraction