Optimal Common Subsequence
Medium
Execution time limit is 0.1 seconds
Runtime memory usage limit is 256 megabytes
Given two strings and , which consist of lowercase Latin letters and digits.
Find the string of the shortest length that includes strings and as subsequences and output its length. It is allowed for the strings and to appear with gaps in the desired string, but it is important that the sequence of characters of strings and is preserved in the desired string.
Input
The first line of the input contains the string , the second line contains the string .
The length of strings and does not exceed characters.
Output
Output a single number – the length of the shortest string that includes strings and .
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Input #4
Answer #4
Submissions 61
Acceptance rate 23%