Task: Text to Code
Input (English): Step 1: For each row in Has_Allergy table, find corresponding rows in Allergy_Type table and in Student table.
Step 2: find the number of rows in the results of step 1 whose Sex equals M and AllergyType equals food
Output (English): SELECT Count ( * ) FROM Allergy_Type AS T1 JOIN Has_Allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T2.StuID = T3.StuID WHERE T3.Sex = "M" AND T1.AllergyType = "food"