The preference is given to the best candidate. Sounds trite, but it's true. To be fair, there are some programs who prefer pathology backgrounds (perhaps because the dermatopathologists are pathology trained) and others who prefer dermatology background for similar reasons. Some programs with two spots want one of each (because the other half of the fellowship is either clinical derm or general surgical pathology, and it might be hard to fit in two people in one of these tracks).