-- Database schema
| cars : id [ INTEGER ] primary_key , train_id [ INTEGER ] cars.train_id = trains.id , position [ INTEGER ] , shape [ TEXT ] , len [ TEXT ] , sides [ TEXT ] , roof [ TEXT ] , wheels [ INTEGER ] , load_shape [ TEXT ] , load_num [ INTEGER ] | trains : id [ INTEGER ] primary_key , direction [ TEXT ] |
-- -- Among the trains that run in the east direction, how many of them have more than 2 long cars?

SELECT SUM(CASE WHEN T2.longCarsNum > 2 THEN 1 ELSE 0 END)as count FROM trains AS T1 INNER JOIN ( SELECT train_id, COUNT(id) AS longCarsNum FROM cars WHERE len = 'long' GROUP BY train_id ) AS T2 ON T1.id = T2.train_id WHERE T1.direction = 'west';