The ‘secret’ is not to try to force any such thought from the mind or circumvent or deny the thought. Just accept them in a choiceless fashion. You don’t have to approve of them. Don’t even go there. Don’t even start to judge the thought in any way. And if the thought be a 'negative' one, there is no need to override it with a 'positive' one. Just let them alone.
Thoughts are only thoughts. They are a function of consciousness. In and of themselves they have no substantive 'reality'---and no power to hurt you---unless you chose to identify with them and thus give them a significance that they don't otherwise deserve. So, choose to be choicelessly aware at all times. As you do that, from one moment to the next, you may well find that when you are aware---choicelessly so---of the fact that you are thinking, all thinking tends to stop. Amazing!
Peace to you.