str_lst = [input() for i in range(2)]
str1, str2 = list(str_lst[0]), list(str_lst[1])
matrix_2d = [[0] * (len(str1) + 1) for i in range(len(str2) + 1)]
for i, a in enumerate(str2):
for j, b in enumerate(str1):
if a == b:
matrix_2d[i + 1][j + 1] = matrix_2d[i][j] + 1
elif a != b:
matrix_2d[i + 1][j + 1] = max(matrix_2d[i + 1][j], matrix_2d[i][j + 1])
print(matrix_2d[-1][-1])