-- Database schema
| users : userid [ INTEGER ] primary_key , age [ TEXT ] , u_gender [ TEXT ] , occupation [ TEXT ] | directors : directorid [ INTEGER ] primary_key , d_quality [ INTEGER ] , avg_revenue [ INTEGER ] | actors : actorid [ INTEGER ] primary_key , a_gender [ TEXT ] , a_quality [ INTEGER ] | movies : movieid [ INTEGER ] primary_key , year [ INTEGER ] , isEnglish [ TEXT ] , country [ TEXT ] , runningtime [ INTEGER ] | movies2actors : movieid [ INTEGER ] , actorid [ INTEGER ] , cast_num [ INTEGER ] | movies2directors : movieid [ INTEGER ] , directorid [ INTEGER ] , genre [ TEXT ] | u2base : userid [ INTEGER ] , movieid [ INTEGER ] , rating [ TEXT ] |
-- -- Among the films directed by directors who direct the best, how many of them have an average rating of over 3.5?

SELECT COUNT(*) FROM ( SELECT DISTINCT T2.movieid FROM directors AS T1 INNER JOIN movies2directors AS T2 ON T1.directorid = T2.directorid INNER JOIN u2base AS T3 ON T2.movieid = T3.movieid WHERE T1.d_quality = 5 GROUP BY T2.movieid HAVING AVG(T3.rating) > 3.5 ) AS T1;