The Pandavas spent 13 years in exile: 12 years in the forest followed by a 13th year living incognito. This was the punishment imposed after Yudhishthira lost a dice game against Shakuni.
During the forest period, the brothers and Draupadi faced hardship, encountered sages and supernatural beings, and gained powerful weapons and alliances. Arjuna undertook severe austerities and received celestial weapons from the gods, preparing for the conflict that would eventually become the Kurukshetra War.
The final year was called ajnatavasa, or life in concealment. The Pandavas lived in King Virata’s kingdom under disguises: Yudhishthira served as a court adviser, Bhima worked as a cook, Arjuna taught dance while disguised as Brihannala, and Nakula and Sahadeva cared for horses and cattle. Draupadi served as a lady-in-waiting.
A frequent source of confusion is the answer 12. That number refers only to the forest exile. The complete penalty lasted 13 years, with the last year requiring secrecy; discovery would have triggered another cycle of exile.