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
s = raw_input()
t = raw_input()
s_count=0
t_count=0
while(t_count < len(t) and s_count < len(s)):
    if s[s_count]==t[t_count]:
        s_count = s_count + 1
    t_count =  t_count + 1

print s_count