When Pandavas won the battle of Kurukshetra at that time Dhritarashtra was the ruler of Hastinapur. After that, he went to exile with Gandhari and Kunti. Then Pandavas ruled in the Hastinapur and established the rule of religion. How many years did they take the time for this religious establishment in Hastinapur?
Pandavas solely ruled Hastinapura themselves for 21 years , Pandavas ruled Hastinapura keeping obedience to Dhritarashtra's words (under him) for 15 years. After that Dhritarashtra decided to follow vanaprastha ashrama with Gandhari and Kunti by constant harsh words of Bhima.
And 36 years after Kurukshetra war Pandavas decided their MahaPrasthana, after hearing Lord krishna's departure from this world and great slaughter of Yadu race .
After Kurukshetra war Yudhishthira became installed on the throne of Hastinapura under guidance of Dhritarashtra
ततः परत्यर्चितः सद्भिर धर्मराजॊ युधिष्ठिरः |
परतिपेदे महद राज्यं सुहृद्भिः सह भारत ||22||
Yudhishthira the just, with his friends, became installed on the throne of a large kingdom, O Bharata!'" |Shanti Parva -Rajadharmanusasana Parva- SECTION XLI
ततः पञ्चदशे वर्षे समतीते नराधिपः|
राजा निर्वेदम आपेदे भीम वाग बाणपीडितः|| 12||
After five and ten years had passed away, O monarch, king Dhritarashtra afflicted (constantly) by the wordy darts of Bhima. | SECTION III -Asramavasika Parva.
After that Dhritarashtra went into VanaPrastha Ashrama A described in Ashram Vasika Parva -SECTION XV - of Mahabharata .
Dhritarashtra, having settled the hour of his departure for the woods, summoned those heroes, the Pandavas. Possessed of great intelligence, the old monarch, with Gandhari, duly accosted those princes. Having caused the minor rites to be performed, by Brahmanas conversant with the Vedas, on that day which was the day of full moon in the month of Kartika, he caused the fire which he worshipped daily to be taken up. Leaving his usual robes he wore deer-skins and barks, and accompanied by his daughters-in-law, he set out of his mansion.
Upon hearing of Lord Krishna’s ascension to heaven , and great slaughter of the Vrishnis. King Yudhishthira decided of leaving the world.
षट तरिंशे तव अथ संप्राप्ते वर्षे कौरवनन्दन |
ददर्श विपरीतानि निमित्तानि युधिष्ठिरः || 1||
Vaishampayana said: "When the thirty-sixth year (after the battle) was reached, the delighter of the Kurus, Yudhishthira, beheld many unusual portents. Book 16: SECTION 1- Mausala Parva
शरुत्वैव कौरवॊ राजा वृष्णीनां कदनं महत |
परस्थाने मतिम आधाय वाक्यम अर्जुनम अब्रवीत ||2||
Vaishampayana said: "Having heard the particulars of the great slaughter of the Vrishnis, the Kaurava king set his heart on leaving the world. He addressed Arjuna, saying, ‘O thou of great intelligence, it is Time that cooks every creature (in his cauldron). I think that what has happened is due to the cords of Time (with which he binds us all). It behoveth thee also to see it.’ Book 17: SECTION 1 -Mahaprasthanika Parva
So After Kurukshetra war Pandavas ruled for 36 years out of which they spend 15 years under Dhritarashtra's guidance and ruled themselves solely for 21 years.