#P12173. Maximizing Favorite Substrings

    ID: 14276 Type: Default 1000ms 256MiB

Maximizing Favorite Substrings

Maximizing Favorite Substrings

Little Blue has a string \( s \). He especially likes words composed only of the three characters \( \tt{l} \), \( \tt{q} \), and \( \tt{b} \). In particular, he loves any word that is a permutation of \( \tt{lqb} \). There are exactly six possibilities:

(\tt{lqb}, \tt{lbq}, \tt{qlb}, ( \tt{qbl}, \tt{blq} ), and ( \tt{bql} ).

Your task is to determine the maximum number of non-overlapping contiguous substrings that Little Blue can cut from \( s \) where each substring is exactly one of his favorite words. Note that substrings must consist of exactly 3 characters.

inputFormat

The input consists of a single line containing the string \( s \), which is composed of lowercase letters.

outputFormat

Output a single integer representing the maximum number of non-overlapping substrings that are a permutation of \( \tt{lqb} \).

sample

lqblqb
2