It is better to daven with a small minyan in a Beis Medrash (where people regularly learn Torah) than with a larger minyan in a Shul (if they don’t learn Torah). This is learned from the passuk “HaShem loves the gates of Zion (gates that learn Torah. see Gemara Berachos 8a and Shulchan Aruch O.C. 90:18 with MB there which explains the derasha) more so than all the dwellings of Yaakov (the Shuls)” (ibid).
Of course, BTYA is best of all!