Two Brothers

Time Limit: 2000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 1758
64-bit integer IO format: %I64d      Java class name: Main

Description

Though Yueyue and Lele are brothers , they are very different.
For example, Yueyue is very hard in study, especially in writing compositions. To make the composition looks nice , he will not use the same word twice. While Lele is very lazy, and he sometimes copys his brother's homework.

Last week, their teacher asked them to write a composition named "My Mother", they handed the same composition. The teacher was very angry , but Lele just answered "We have the same mother , why should our compositions be different ?"

Now,the teacher is asking Yueyue and Lele to write the compositions again, and he wants to calculate the length of longest common subsequence of words occuring in the two compositions. Can you help him ?

Input

There will be many test cases in the problem.Please process to the end of file.
Each case contains two lines.
The first line means Yueyue's composition and the second line means Lele's composition.
Each composition will contains no more than 10^4 words . And each word will contains less than 40 characters.Each character will only be in a~z or A~Z.
Two words will be separated by a blank.

To make the problem easier, there will be a "#" at the end of each composition.

Output

For each case , output a integer in a line represents the length of longest common subsequence of words occuring in the their compositions.

Sample Input

aa bb cc #
aa cc bb #

Sample Output

2

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .