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()
sind = 0
tind = 0
lt = len(T)
ls = len(S)
count = 0
while(tind<lt and sind<ls):
	curr = S[sind]
	while(tind < lt and T[tind]!=curr):
		tind+=1
	if(tind<lt):
		count+=1
	sind+=1
	tind+=1

print count