e-olymp
Competitions

Sequences + Longest Common Subsequence

Letter Deletion

You are given two words (each word consists of upper-case English letters).

Try to delete some letters from each word so that the resulting words are equal.

What is the maximum possible length of the resulting word?

Input

There will be no more than 10 test cases.

Each test case consists of a single line, contaning the two words separated by a single space. The length of each of these words is between 1 and 200.

Output

For each test case output the maximum length of a resulting word (the length of the longest word that can be created from both words by removing some letters).

If the two words have no letters in common, output 0.

Time limit 1 second
Memory limit 128 MiB
Input example #1
AAABBB ABABAB
AXYAAZ CCCXCCCYCCCZCC
ABCDE EDCBA
Output example #1
4
3
1