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
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
s, t = raw_input(), raw_input()
x = y = 0
while x < len(s) and y < len(t):
	if s[x] == t[y]:
		x += 1
	y += 1
print x