cho.sh
Notes
Loading...

LCS of Three Strings

Time limit

2s

Memory limit

128 MB

Problem

Given three strings, find the length of the longest subsequence that appears in all three strings.

A subsequence is obtained by deleting zero or more characters from a string while preserving the relative order of the remaining characters.

Input

The first line contains the first string, the second line contains the second string, and the third line contains the third string.

All three strings consist only of lowercase English letters, and each string has length at most 100.

Output

Print the length of the LCS of the three strings on the first line.