#P1163D. Mysterious Code
Mysterious Code
Description
During a normal walk in the forest, Katie has stumbled upon a mysterious code! However, the mysterious code had some characters unreadable. She has written down this code as a string consisting of lowercase English characters and asterisks ("*"), where each of the asterisks denotes an unreadable character. Excited with her discovery, Katie has decided to recover the unreadable characters by replacing each asterisk with arbitrary lowercase English letter (different asterisks might be replaced with different letters).
Katie has a favorite string and a not-so-favorite string and she would love to recover the mysterious code so that it has as many occurrences of as possible and as little occurrences of as possible. Formally, let's denote as the number of occurrences of in (for example, ). Katie wants to recover the code conforming to the original , such that is largest possible. However, Katie is not very good at recovering codes in general, so she would like you to help her out.
The first line contains string () — the mysterious code . It is guaranteed that consists of lowercase English characters and asterisks "*" only.
The second and third line contain strings and respectively (, ). It is guaranteed that and consist of lowercase English characters only.
Print a single integer — the largest possible value of of the recovered code.
Input
The first line contains string () — the mysterious code . It is guaranteed that consists of lowercase English characters and asterisks "*" only.
The second and third line contain strings and respectively (, ). It is guaranteed that and consist of lowercase English characters only.
Output
Print a single integer — the largest possible value of of the recovered code.
Note
In the first example, for equal to "katie" and , which makes which is the largest possible.
In the second example, the only conforming to the given is "caat". The corresponding .
In the third example, there are multiple ways to recover the code such that is largest possible, for example "aaa", "aac", or even "zaz". The value of for all of these recovered codes.
In the fourth example, the optimal recovered code would be "ccc". The corresponding .