Yes, math counts. Given that most med school applicants (except those with loads of AP credits) take a year's worth of 4 sciences (chem, o-chem, bio & physics) plus, in many cases, some stats and /or math, there should be 2 people you can choose. We do recognize that some schools have huge lecture halls and limited opportunities for students to get to know the teachers. In these cases, some professors write based on the grade book but even those letters can be helpful if they illustrate your hard work at overcoming a poor start, or your consistency in earning good grades throughout the term, or your slacking off at the end after guaranteeing yourself enough points to earn the grade you felt that you needed. (Yes, I've seen a letter like that! 😱 ) Professors writing from the gradebook can also put your grade in the context of the class' performance which helps us understand grade inflation (or lack thereof) in the classroom... someone might say that you were consistently in the top 3 in a class of 300... or that your A- places you in the top 15% of a strong class of engineering students.
Other things that professors can tell us even if you don't know them well: that you came for help when you didn't understand something, that you were so sharp & on top of things that you never came for help.
This stuff isn't really obvious until you've seen several thousand letters from more than a hundred different schools.