You have nothing to worry about. Your teacher did not use a compound of mercury. It was probably pure mercury metal. Exposure of a second or two is totally insignificant. People who get sick from mercury poisoning are exposed for hours and hours over many days and even years. Metallic mercury which you touched is not such a big deal. The bigger problem is with organomercury compounds. That is: mercury that has combined with carbon and other elements to form larger molecules that are biologically active. Mercury has to be vaporized and inhaled to become a problem to humans. You were not exposed in this way.
The relationship between mercury and multiple sclerosis has not been demonstrated scientifically. In fact it is a false idea that is used by quacks to sell unnecessary medical and dental treatments that are not needed. Read this report on QuackWatch.