#1 - realize that minds change in med school and be open to everything. That said, a rough timeline of med school assumming derm is the goal:
MS1: relax about residency and just focus on getting the best grades you can - you'll need them.
MS2: focus on preparing for Step 1: you are shooting for 230+. Study for the boards sections pertaining to your classes while you study for exams. Also keep getting good grades. Join or start dermatology interest group at your school (maybe do this is year 1, but don't get too crazy). Did I mention the boards?
MS3: If your grades are kick-azz and your board scores are good (for derm: >230), push forward. If you think you've already got a few "dings" on your record, or if you're top-notch and just want to "make sure" you're going to get into derm, consider applying for a fifth-year option and take a year to do derm research in between MS3 and MS4. Set up away rotations to get derm letters of recommendation. Focus on HONORS in your clinicals no matter what the specialty.
MS4 (or 5 if you do research): Do your away rotations, do well, impress, get letters. Apply to residency, hopefully get in. If not, regroup and try again.
You have a unique opportunity to excel knowing what you want to do before med school. Plan it right and you will achieve it.