s0 = input()
s1 = input()
m, n = len(s0), len(s1)
dp = [[0 for i in range(n + 1)] for j in range(m + 1)]#dp是递推,大小需要多个1
for i in range(m):
    for j in range(n):
        if s0[i] == s1[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
print(dp[m][n])