Problem1615--Longest not descending subsequenceⅡ

1615: Longest not descending subsequenceⅡ

[Creator : ]
Time Limit : 1 sec  Memory Limit : 128 MB

Description

   To find the length of the longest not descending subsequence witch is expressed by letters and the way to sort is given.

Input

   The first line contains 26 different characters which represents the way to sort.

  The second line contains some words and Enter the last.


Output

   For every words, output the length of the longest not descending subsequence and no space divided.

Sample Input Copy

abcdefghijklmnopqrstuvwxyz
abcd efg hhh ihg

Sample Output Copy

4331

Source/Category

JoyOI