SP2816 CSUBSEQS - Common Subsequences

Description

You are given four strings, each consisting of at most 50 lower case letters ('a'-'z'). Count the number of non-empty common subsequences of them (the number of distinct non-empty strings which are subsequences of all four strings). Note that a subsequence does not have to be contiguous.

Input Format

Four lines: each line consists of a single string.

Output Format

An integer representing the answer.