SELECT COUNT(*) AS KoduSkaits 
FROM Kuponi 
WHERE kods REGEXP '^B*AB*AB*$';