William just finished his AP English reading comprehension test and is worried about his score. The test has A
, B
, C
, or D
.
Thankfully, his friend Kevin already took the test and got a perfect score. Eager to know how he did, William asks him for his answers so that he can compare.
However, Kevin has a very foggy memory, and only remembers the answers to some questions on the test. For each question, he writes ?
if he forgot the answer or the correct answer otherwise, recording them in a string A
, B
, C
, and D
, denoting them
William recieves this information in a message from Kevin, but he's not sure what to do with it. As he's a chronic overthinker and a pessimist, he wants to determine the lowest mark he could possibly recieve. Can you write a program to help him?
Constraints
For all subtasks:
Subtask 1 [5%]
Kevin remembers the answer to every question.
Subtask 2 [60%]
Kevin remembers the answer to no questions.
Subtask 3 [35%]
No additional constraints.
Input Specification
The first line contains the integer
The second line contains the string
The third line contains the string
The fourth line contains the integers
Output Specification
The output contains one integer, the minimum number of questions that William could have gotten right.
Sample Input 1
9
DBCADDACB
D?C???BC?
1 1 2 5
Sample Output 1
4
Explanation for Sample 1
It can be proven that William will always get a minimum of 4 questions right.
The following is a possible answer key that would fulfill Kevin's data and lead to 4 correct answers:
Scantron: DBCADDACB
Known Answer Key: D?C???BC?
Possible Answer Key: DDCDDABCD
Correct: YNYNYNNYN
Sample Input 2
12
BBCCCBAABAAA
BBCCABCBBABA
3 6 3 0
Sample Output 2
8
Explanation for Sample 2
This case satisfies the conditions of Subtask 1.
William got questions 1, 2, 3, 4, 6, 9, 10, and 12 right, so he got a total of 8 questions right.
Comments