The Hogwarts has set up a new course recently, giving you the ancient spells and requiring you to translate them into the modern ones. Every two ancient spells encode one modern spell.
Wizards and witches just point the ancient spells with the magic wands and speak loudly "THE LONGEST COMMON SUBSEQUENCE !", and they'll get the modern spell required:)
Ok, stop trying this muggles...Though we can't get the answers as quickly as they do, we can still decode them by coding :)
So Bamboo will give you a lot of ancient spells( two in a group),and hope you just return the LENGTH of the modern spell.
Attention please! The ancient spells may include strange characters '#' and '?'. They are too old to know their exact meanings, so we can just think that '#'s can not match any character while finding the answer, but '?' can match any character in the other ancient spell except '#'.
The input file consists of several test cases.
Each test case includes 2 lines, one ancient spell per line.
The length of per ancient spell will less than 100 characters,and all characters are in upper case.
For each case, output one line: the length of the modern spell.
ABCDE
ZBD
AC#EB
C#BFG
ACE#?
KIKI#A
???
?#?
2
2
1
2
emmmm, Can you guess what 'spell' means here? And what about the modern spells? Pay attention to what wizards and witches say when they use magic.
In case 2, '#' can not match any character, just like it doesn't exist, so the modern spell is "CB".
In case 3, '?' can match any character except '#', which means '?' can be seen as ‘A~Z' and '?' of course.