To find the length of the longest not descending subsequence witch is expressed by letters and the way to sort is given.
The first line contains 26 different characters which represents the way to sort.
The second line contains some words and Enter the last.
abcdefghijklmnopqrstuvwxyz
abcd efg hhh ihg
4331