Over-remove, then give back
Subtracting 40 is easier than subtracting 38. You took away 2 extra, so you return those 2. Rounding up when subtracting always means adding back.
Why it works
Take 40 dollars to be safe, then realize you only owed 38, so you keep 2.