#K71177. Longest Common Subsequence

    ID: 33474 Type: Default 1000ms 256MiB

Longest Common Subsequence

Longest Common Subsequence

You are given two strings S1 and S2. Your task is to compute the length of the longest common subsequence (LCS) between these two strings.

The longest common subsequence of two strings is the longest sequence that appears in both strings in the same relative order, but not necessarily contiguous.

Note: The input will be provided via stdin and your result should be printed to stdout.

Example:

Input:
abcde
ace

Output: 3

</p>

inputFormat

The input consists of two lines. The first line contains the string S1 and the second line contains the string S2.

outputFormat

Output a single integer representing the length of the longest common subsequence between S1 and S2.## sample

abcde
ace
3