<?php
fwrite($stdin, "2\nAaBbCc\nXxYyZz\n"); while(true) {
$t = (int)$t;
while($t--) {
$sLen=0;
$subStringsNum=0;
$searchString="";
$searchString = fread($stdin,20); for($i=0;$i<$sLen;$i++) {
for($j=$i;$j<$sLen;$j++) {
if(preg_match("/^[A-C]+$/i",substr($searchString,$i,$sLen-$j))) {$subStringsNum++;} }
}
echo $subStringsNum."\n";
}
}
?>
PD9waHAKCiRzdGRpbiA9IHRtcGZpbGUoKTsKZndyaXRlKCRzdGRpbiwgIjJcbkFhQmJDY1xuWHhZeVp6XG4iKTsKZnNlZWsoJHN0ZGluLCAwKTsKICAgIHdoaWxlKHRydWUpIHsKICAgICAgICAkdCA9IGZyZWFkKCRzdGRpbiwzKTsKICAgICAgICAkdCA9IHRyaW0oJHQpOwogICAgICAgICR0ID0gKGludCkkdDsKICAgICAgICB3aGlsZSgkdC0tKSB7CiAgICAgICAgICAgICRzTGVuPTA7CiAgICAgICAgICAgICRzdWJTdHJpbmdzTnVtPTA7CiAgICAgICAgICAgICRzZWFyY2hTdHJpbmc9IiI7CiAgICAgICAgICAgICRzZWFyY2hTdHJpbmcgPSBmcmVhZCgkc3RkaW4sMjApOwogICAgICAgICAgICAkc0xlbj1zdHJsZW4oJHNlYXJjaFN0cmluZyk7CiAgICAgICAgICAgICRzTGVuPXN0cmxlbih0cmltKCRzZWFyY2hTdHJpbmcpKTsKICAgICAgICAgICAgZm9yKCRpPTA7JGk8JHNMZW47JGkrKykgewogICAgICAgICAgICAgICAgZm9yKCRqPSRpOyRqPCRzTGVuOyRqKyspIHsgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICBpZihwcmVnX21hdGNoKCIvXltBLUNdKyQvaSIsc3Vic3RyKCRzZWFyY2hTdHJpbmcsJGksJHNMZW4tJGopKSkgeyRzdWJTdHJpbmdzTnVtKys7fQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGVjaG8gJHN1YlN0cmluZ3NOdW0uIlxuIjsKCiAgICAgICAgfQogICAgICAgIGRpZTsKICAgIH0KPz4=