include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
const int N = 2010;
int q[N][N];
int main()
{
string a,b;
cin>>a>>b;
int al = size(a),bl=size(b);
int cnt = 0;
for(int i = 1;i <= al;i++)
{
for(int j = 1;j <= bl;j++)
{
if(a[i-1] == b[j-1]) q[i][j] = q[i-1][j-1] + 1;
else q[i][j] = max(q[i][j-1],q[i-1][j]);
cnt = max(cnt,q[i][j]);
}
}
cout<<cnt<<endl;
}