Fibre. Either something like psyllium husk taken at hourly intervals with plenty of water or a change to your actual diet to increase fibre.
Look at foods high in fibre - Nuts, Fruit and eat more.
A single anti-diarrhea (loperamide) tablet can help.
The problem with using drugs - is you have to know how it will effect you and there is risk in using them unnecessarily.
For fibre - if you are not used to taking it can make you feel bloated and/or depending on digestion may take time to pass through.
So you need to do a bit of experimenting.
Personally I find some fibre bars to 'snack on' plus an increase in the fruit+nuts I usually eat most days works well for me.
If there is an occasion I will add 3 double doses of psyllium.
Listen to your body when discovering what works for you. This might be a 3 day+ process to get a 12hr window in which the right kind of shit happens