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
s1 = raw_input()
s2 = raw_input()
i=0
j=0
while i<len(s1) and j<len(s2):
	if(s1[i]!=s2[j]):
		j=j+1
	else:
		i=i+1
		j=j+1
print i