eolymp
bolt
Try our new interface for solving problems
Problems

Removing the letters

Removing the letters

You are given two words (each word consists of upper-case English letters). Delete some letters from each word so that the resulting words become equal.

Find the maximum possible length of the resulting word.

prb1079.gif

Input

Each test case consists of a single line, containing two words separated by a space. The length of each of these words is between 1 and 200. There are no more than 10 test cases.

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 two words have no letters in common, print 0.

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