If you have the year in A1 e.g. 2017 and quarter number in B1, e.g. 4 then this formula will give you the total number of weeks in that quarter, counting weeks if the Wednesday of that week is within the quarter
=NETWORKDAYS.INTL(DATE(A1,B1*3-2,1),DATE(A1,B1*3+1,0),"1101111")
Using this method ensures that every week is counted in one quarter only.
Unsurprisingly, as every quarter is between 90 and 92 days, this will give you 13 in most cases - only giving 14 if Q3 or Q4 starts on a Wednesday or 12 if Q1 in a non leap year starts on a Thursday