I got the impression that Yash RS and LayDhammaFollower were thinking of the problem too hard. (No offense, I once had the same concern too.)
What one has to do is quite simple if one has enough comprehension of Anapanasati, Tilakkhana, Four noble truths, and Paticca Samuppada.
(i) Stop thinking and acting on those things while contemplating the adinava of sensual pleasure. (apana, passasati)
(ii) Do think and focus on a better feeling (such as niramisa sukha). (ana, assasati)
(iii) Keep one and two steps until attaining anagami.
Though, I would like to hear Lal’s comment. I think lal could explain better than I did.
+) I didn’t see Lal’s comment above while posting it.