Welcome to HCM,
You can do so by focussing your attention to your study or your hobby,but masturbation
is quite natural in males oof your age so do not feel any thing or bad about it.Even it is safe if you do it daily it is stress
I would suggest you to pay attention to your sdudies and once in a while maturbation is OK and will help you to focus in your study.
Please take care of your diet and exercise like play some out door sports.