this problem imaginary language BHTML BCSS slightly resemble html css Read problem statement carefully resemblance slight problem use simplify analogsyou give bhtml document resemble html simple it record sequence open closing tag a tag look like tagname call opening tag tag look like tagname call closing tag besides selfclose tag write tagname problem fully equivalent tagnametagname all tagname problem string consist lowercase latin letter length 1 10 character tagname different tag coincidethe document tag form correct bracket sequence obtain sequence give follow operation remove selfclose tag tagname remove pair opening closing tag consecutively order name in word remove substre tagnametagname for example give document headerpabbpheaderfooterfooter give document ab aa ababobviously open tag matching closing pair call element a selfclose tag element Lets consider element nest inside tag element tag second an element nest for instance example element b nest header p is not nest footer is not nested b element header element nest footer zeroWe need bcss rule apply style display element bhtml document each rule record subsequence word x1 x2 xn this rule effect element t satisfy condition list sequence nest element tagname x1 x2 xn second element nest element nest second sequence end element t ie tagname element t equal xn for example element b meet condition rule b element b exist element nest Element c meet condition rule b b c element exist b b chain abbc follow element nest previous onegiven BHTML document set bcss rule write program determine number element meet condition rule