You are given two string S and T. Find the maximal length of some prefix of the string S which occurs in strings T as subsequence.

Input
The first line contains string S.
The second line contains string T.
Both strings consist of lowecase Latin letters.

Output
Output one integer - answer to the question.

Constraints
1 ≤ length of S, T ≤ 10^6

SAMPLE INPUT
digger
biggerdiagram

SAMPLE OUTPUT
3
src = list(raw_input().strip())
tgt = list(raw_input().strip())


lsrc = len(src)
ltgt = len(tgt)

maxlen = 0
for i in range(ltgt):
    if tgt[i] == src[maxlen]:
        maxlen+=1
        if maxlen==lsrc:
            break
print maxlen