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=list(raw_input())
t=list(raw_input())

l=len(s)
n=len(t)
i=0
j=0
arr=[]
while i<n:
	if t[i]==s[j]:
		arr.append(t[i])
		if j==l-1:
			break
		
		if j<l:
			j+=1
	i+=1
	
print len(arr)