ANSWER:
If the spotting comes before the flow of blood of menses, this is not part of it. You should pray and fast as usual.
But if it comes during the menses or after it before seeing your purity, it is part of menses, unless it exceeds 15 days.
Purity is identified by seeing a white thread like discharge or by experiencing complete dryness. If you saw your purity once the flow of blood has stopped, you may take ghusl and disregard any spotting that comes afterwards as nothing, being keen to renew your wudhu before each prayer.