this depends a lot on where you live and how strict they reinforce drug laws.
that being said though, the majority of judges just want what is best for you. if you are serious about getting clean, and these are the first charges you've managed to pick up, you've got a fighting chance- especially because you're so young. jails and prisons are overcrowded as it is. the reason so many individuals are doing time is because their judge/court system was well aware it would probably be the only way they would get cleaned up. whether or not that sticks after the get out is a different story.
do you have a lawyer? if so, talk to him. just be honest. explain that you have an addiction, which is the only reason you are in this mess of a situation- hopefully this is the case. i would go with something along the lines of:
"i know that i am solely responsible for my actions which have left me in the situation i'm in, there's no doubt about that. i recognize that i have a serious problem and i want to fix it so i can have a better future. i'm only 18 and was always a good kid until i foolishly allowed myself to get caught up in drugs (if this part is true, i hope that it is!). my addiction has already ruined my life in countless ways and i will do anything for a second chance. i want to have options in my future. i want to get clean so i can better myself. with the charges i am facing, i will be limited to paths that aren't exactly desirable to me. i am fully aware that my choices, and my choices alone have brought this upon me. i am begging for the opportunity to get myself into rehabilitation. i want my life and myself back. i honestly don't even know who i am anymore and i will have to live with this shame and regret for the rest of my life." etc etc etc. you don't need to do all this ver batem, but just so you get the idea. be sure to make it clear that you are serious about changing your ways, that you are disappointed in yourself, and will take any actions necessary for a second chance .
i would also take the time to write a letter/essay/whatever, or find out about talking personally to the judge handling your case (or a judge who normally handles drug related sentencing)/court system. this has worked in the favor of many people i know. if they can tell that you are truly regretful and want to better yourself, you have a good chance of getting mandatory rehabilitation and probably probation. like i said before though, it depends a lot on if these are your first offenses. be assertive and make changes that will help sway them.
my laptop is dying, i need to plug it in- but PM me if you'd like. sorry this was so unorganized and repetitive. i'll get back to you with more useful info.