Help me in solving ABCC problem

My issue

Should we take just the first occurrence of abc or any abc works?
for example in string “bbcaccbaaccabc” shall we take bbcAccBaaCcabc or bbcaccbaaccABC?
(caps are just to represent selections)

Problem Link: ABC Conjecture Practice Coding Problem - CodeChef