Panini has written a great treatise called Ashtadhyayi on Sanskrit Vyakarana (grammar). Katyayana has written Vartika i.e commentary on Panini's Ashtadhyayi which became core part to Sanskrit grammar. Patanjali further elaborated on Ashtadhyayi along with Vartika of Katyayana in his work called Mahabhashya which discuss selected verse of Astadhyayi long with Vartika. By the way these three Munis (Panini, Katyayana and Patanjali) who have done such a great work on Sanskrit grammer are known as MuniTraya (मुनित्रय).
Panini's Ashtadhyayi starts with:
Now an explanation of words
The Sutras found in 1st pada of 1st Adhyaya of Panini's Ashtadhyayi are discussed along with Vartika of Katyayana in 9 āhnika. The fitst āhnika is पस्पशाह्निक (IAST: paspaśāhnika).
Citing the line of paspaśāhnika talk about Veda Shakhas from Sanskrit Wikisource
(प-१२; अकि-१,८.२३-१०.३; रो-१,३५-३९; भा-४९/६२) सप्तद्वीपा वसुमती त्रयः लोकाः चत्वारः वेदाः साङ्गाः सरहस्याः बहुधा विभिन्नाः एकशतम् अध्वर्युशाखाः सहस्रवर्त्मा सामवेदः एकविंसतिधा बाह्वृच्यम् नवधा आथर्वणः वेदः वाकोवाक्यम् इतिहासः पुराणम् वैद्यकम् इति एतावान् शब्दस्य प्रयोगविषयः ।
You can refer Mahabhashya in IAST here. The present Bhashya by Patanjali is on 12th sutra of Ashtadhyayi, refer pg. 9.
saptadvīpā vasumatī trayaḥ lokāḥ catvāraḥ vedāḥ sāṅgāḥ sarahasyāḥ bahudhā vibhinnāḥ ekaśatam adhvaryuśākhāḥ sahasravartmā sāmavedaḥ ekaviṃsatidhā bāhvṛcyam navadhā ātharvaṇaḥ vedaḥ vākovākyam itihāsaḥ purāṇam vaidyakam iti etāvān śabdasya prayogaviṣayaḥ ।
Quoting the full page from Mahabhashya Vol 1: (Sanskrit text with Hindi translation)
Some English translation version of Ashtadhyayi and Mahabhashya are available on Internet Archive e.g. this and this. I'm finding bit trouble for locating present line for time being.
Referring to original Sanskrit and Hindi translation it's clear that
- एकशतम् अध्वर्युशाखाः = 101 Shakha of Yajurveda
- सहस्रवर्त्मा सामवेदः = 1000 Shakha of Samaveda
- एकविंसतिधा बाह्वृच्यम् = 21 Shaka of Rigveda
- आथर्वणः वेदः वाकोवाक्यम् = 9 Shaka of Atharvaveda
So, totaling 101 + 1000 + 21 + 9 = 1131 number of Shakhas.
Translation of the relevant bhāṣya from Surendranath Dasgupta's incomplete work published posthumously:
Make efforts in discovering them. The field for the use of words is very
large. There are the seven islands of the earth, three worlds, the four Vedas
with their accessories and esoteric doctrines diversely varied. There are
the hundred branches of the Adhvaryuveda and thousand ways of
Sāmaveda, twenty-one-fold Bāhvṛcya, ninefold Ātharvaṇaveda, the dialogue literature, legends and purāṇas, medical science, so much is the field
of the use of words. Without examining such a large field of the
application of words, to say that there are words which are not used, is