All Submissions


A magic string t of any string S is any string that can be obtained by deleting (zero or more) characters from String S. You are given two strings A and B, you need to output the length of largest magical string which can be obtained from both A as well as B.

Input

Two strings A and B on two lines, With string length(1<=len<=10^3).

Output 

Print the answer required.

Sample Input

abcdef

bcfg

Sample Output

3

Explanation:

bcf is the longest magical string that can be obtained.

 


Languages: AWK,Bash,Brain,C,C++,Java,C#,JavaScript,Pascal,Perl,PHP,Python,Python3,Ruby,Text

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

aditya:
Q. 1<=len<=10^3).


aditya:
Q. //I_F_A #include "bits/stdc++.h" using namespace std; bool func(string s){ long long len = s.length(); stack<char> mystack; for(long long i=0;i<len;i++){ if(mystack.empty()){ mystack.push(s[i]); } else{ if(mystack.top() == s[i]){ mystack.pop(); } else{ mystack.push(s[i]);; } } } if(mystack.empty()){

Contest

Mode Judge

Passive

Online

Overall Rankings