Fish have two nostrils on each side of their head, and there is no connection between the nostrils and the throat. The olfactory rosette is the organ that detects the chemicals. The size of the rosette is proportional to the fish's ability to smell.
And fish can't respire through their nostrils, having an incurrent and an excurrent nostril on each side. At some point the excurrent nostril evolved to connect to the throat, leading to the ability to breathe through either mouth or nose. So vertebrates in general have four nostrils, but in land animals, two of them are internal.