Subsequence Pair
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Bobo has two strings s and t. He would like to choose two subsequences x from s and y from t such that:

+ x is lexicographically smaller than or equal to y.
+ The sum of |x| and |y| is maximal, where |s| denotes the length of the string s.

Note that:

+ Both x and y could be empty string.
+ A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.
+ String x is lexicographically less than string y, if either x is a prefix of y (and ), or there exists such i (), that , and for any j () .

输入描述:

The input consists of several test cases terminated by end-of-file. For each test case:

The first line contains a string s. The second line contains a string t.

*
*
* The sum of |s| does not exceed 20000.
* The sum of |t| does not exceed 20000.
* Both the strings consist only of English lowercase letters.

输出描述:

For each test case, output the sum of |x| and |y|.
示例1

输入

复制
aaaa
bbbb
abcd
abca
abcd
abcd

输出

复制
8
7
8