Write SQL query to solve given problem: How many professors teaches no more than two high-level or harder undergraduate courses?. Keep the solution inside sql tag ```sql [SQL-Query] ```
SELECT COUNT(*) FROM ( SELECT COUNT(T2.p_id) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_400' GROUP BY T2.p_id HAVING COUNT(DISTINCT T1.course_id) <= 2 )