SELECT COUNT(*) FROM phones AS p INNER JOIN brands AS b ON b.dbId = p.brands WHERE ( SELECT COUNT(*) FROM phones_ref AS pr INNER JOIN merchants AS m ON m.dbId = pr.merchants WHERE pr.phones = p.dbId AND pr.status = 'a' AND m.status = 'a' ) > 0;