409280: GYM103476 A Missing Letters
Description
After the first snow this winter, students of Innopolis University built a string of letters out of snow. Unfortunately, over time, some of them have collapsed.
One student plans to rebuild new letters instead of the destroyed ones, but they want their initials (a two-letter string made up of the first letters of his first and last name) to appear as often as possible in the rebuilt string. Only occurrences where the student's initials appear as two consecutive letters count. Help them do it.
InputThe first line contains a string consisting of capital English letters and question marks. Question marks correspond to missing letters. The string length ranges from 1 to $$$10^5$$$ characters.
The second line contains a two-letter string — the student's initials.
OutputIn the first line, print the maximum number of times the student's initials can appear in the string after replacing all question marks with letters. In the second line, print the string itself. If there are multiple answers, print any.
ScoringSubtask | Points | Constraints |
1 | 60 | Student's initials are two equal letters |
2 | 40 | No additional constraints |
I?NO?OLIS?PE? OPOutput
2 INNOPOLISOPENInput
???? AAOutput
3 AAAAInput
NONE GGOutput
0 NONE