There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the color of the corresponding stone is red, green, or blue, respectively.

Initially Squirrel Liss is standing on the first stone. You perform instructions one or more times.

Each instruction is one of the three types: "RED", "GREEN", or "BLUE". After an instruction c, if Liss is standing on a stone whose colors is c, Liss will move one stone forward, else she will not move.

You are given a string t. The number of instructions is equal to the length of t, and the i-th character of t represents the i-th instruction.

Calculate the final position of Liss (the number of the stone she is going to stand on in the end) after performing all the instructions, and print its 1-based position. It is guaranteed that Liss don't move out of the sequence.


-----Input-----

The input contains two lines. The first line contains the string s (1 ≤ |s| ≤ 50). The second line contains the string t (1 ≤ |t| ≤ 50). The characters of each string will be one of "R", "G", or "B". It is guaranteed that Liss don't move out of the sequence.


-----Output-----

Print the final 1-based position of Liss in a single line.


-----Examples-----
Input
RGB
RRR

Output
2

Input
RRRBGBRBBB
BBBRR

Output
3

Input
BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB
BBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB

Output
15

Difficulty: EASY

Solutions:
s = input()
t = input()
out = 0
for i in range(len(t)):
	if s[out] == t[i]:
		out += 1
print(out + 1)


s = input()
t = input()
n = len(s)
m = len(t)
j = 0
for i in range(m):
	if j > n:
		break
	if t[i] == s[j]:
		j = j + 1
print(j + 1)


p = input()
instruction = input()
c = 0
positoin = 1
for i in instruction:
	if i == p[c]:
		positoin += 1
		c += 1
print(positoin)


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = 'sonhuytran@gmail.com'
__doc__ = ''
__version__ = '1.0'

def main() -> int:
	(s, t) = (input(), input())
	i = 0
	for instruction in t:
		if instruction == s[i]:
			i += 1
	print(i + 1)
	return 0
exit(main())


s = input()
t = input()
(i, j) = (0, 0)
while i < len(s) and j < len(t):
	if s[i] == t[j]:
		i += 1
	j += 1
print(i + 1)


def compare():
	str1 = input()
	str2 = input()
	step = 0
	for cmd in str2:
		if cmd == str1[step]:
			step = step + 1
	print(step + 1)
	return step + 1
compare()


s = input()
i = 0
for c in input():
	i = i + (s[i] == c)
print(i + 1)


ch = input()
ch1 = input()
s = 1
i = 0
j = 0
for i in range(len(ch)):
	while j < len(ch1):
		if ch[i] == ch1[j]:
			s += 1
			j += 1
			break
		else:
			j += 1
print(s)


s = list(input())
t = list(input())
(i, c) = (0, 1)
for j in t:
	if j == s[i]:
		i += 1
		c += 1
print(c)


s = input()
t = input()
i = 0
for x in t:
	if s[i] == x:
		i += 1
print(i + 1)


s = input()
t = input()
ans = 0
for i in t:
	if s[ans] == i:
		ans += 1
print(ans + 1)


way = input()
moves = input()
pos = 0
for i in moves:
	if i == way[pos]:
		pos += 1
print(pos + 1)


s = input()
t = input()
ii = 0
for i in t:
	if i == s[ii]:
		ii += 1
print(ii + 1)


import sys
inf = float('inf')

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
s = input()
t = input()
length1 = len(s)
length2 = len(t)
i = 0
j = 0
while j < length2:
	if s[i] == t[j]:
		i += 1
	j += 1
print(i + 1)


s = input()
t = input()
ptr = 0
for c in t:
	if c == s[ptr]:
		ptr += 1
		if ptr == len(s) - 1:
			break
print(ptr + 1)


def cs(s, t):
	(i, j) = (0, 0)
	while i < len(t):
		if t[i] == s[j]:
			j += 1
		i += 1
	return j + 1
s = input()
t = input()
print(cs(s, t))


S = input()
T = input()
liss_pos = 0
for i in range(len(T)):
	if T[i] == S[liss_pos]:
		liss_pos += 1
print(liss_pos + 1)


s = input()
t = input()
x = i = 0
while i < len(t):
	if s[x] == t[i]:
		x += 1
	i += 1
print(x + 1)


s = input().strip()
i = input().strip()
l = len(i)
x = 0
y = 0
d = 1
for u in range(l):
	if s[y] == i[x]:
		d += 1
		x += 1
		y += 1
	else:
		x += 1
print(d)


stones = input()
instructions = input()
position = 1
for v in instructions:
	if v == stones[position - 1]:
		position += 1
print(position)


s = input()
t = input()
z = 0
for i in t:
	if s[z] == i:
		z += 1
print(z + 1)


s = input()
t = input()
i = 0
n = len(s)
for tt in t:
	if i < n:
		if s[i] == tt:
			i += 1
	else:
		break
print(i + 1)


import math

def getAns(s, t):
	i = 0
	j = 0
	while j < len(t):
		if t[j] == s[i]:
			i += 1
		j += 1
	return i + 1
strS = input()
strT = input()
print(getAns(strS, strT))


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')
s1 = input().strip()
s2 = input().strip()
i = 0
j = 0
while i < len(s2) and j < len(s2):
	if s1[i] == s2[j]:
		i += 1
	j += 1
print(i + 1)


import sys
import math
s = sys.stdin.readline()
t = sys.stdin.readline()
sl = len(s) - 1
tl = len(t) - 1
j = 0
res = 1
for i in range(tl):
	if s[j] == t[i]:
		res += 1
		j += 1
print(res)


str0 = input()
str1 = input()
counter = 0
for i in str1:
	if i == str0[counter]:
		counter += 1
print(counter + 1)


def calculate(s_str, t_str):
	current_pos = 0
	for char in t_str:
		if char == s_str[current_pos]:
			current_pos += 1
		else:
			continue
	return current_pos
s_str = input()
t_str = input()
steps = calculate(s_str, t_str)
print(steps + 1)


x = input()
y = input()
pos = 0
for i in range(len(y)):
	if x[pos] == y[i]:
		pos += 1
print(pos + 1)


x = input()
y = input()
x = list(x)
y = list(y)
j = 0
for i in range(len(y)):
	if y[i] == x[j]:
		j = j + 1
print(j + 1)


s = input()
t = input()
i = 0
j = 0
index = 0
for i in range(len(s)):
	while j < len(t):
		if s[i] == t[j]:
			j += 1
			index += 1
			break
		else:
			j += 1
print(index + 1)


o = input()
i = input()
l = 0
for p in range(len(i)):
	if i[p] == o[l]:
		l += 1
print(l + 1)


k = input()
i = input()
x = 0
for j in i:
	if k[x] == j:
		x += 1
print(x + 1)


def main():
	s = input()
	t = input()
	i = 0
	for x in t:
		if s[i] == x:
			i = i + 1
	print(i + 1)
main()


stoneseq = [x for x in input()]
instructset = [x for x in input()]
currentcounter = 0
for i in range(len(instructset)):
	if instructset[i] == stoneseq[currentcounter]:
		currentcounter += 1
print(currentcounter + 1)


def main():
	s = input()
	t = input()
	i = 0
	for ti in t:
		if s[i] == ti:
			i += 1
	return i + 1
print(main())


s = input().strip()
ins = input().strip()
x = 0
for i in range(len(ins)):
	if ins[i] == s[x]:
		x += 1
print(x + 1)


s = input()
w = input()
i1 = 0
i2 = 0
n = 0
while i1 != len(s) and i2 != len(w):
	if s[i1] == w[i2]:
		n += 1
		i1 += 1
	i2 += 1
print(n + 1)


s = input()
t = input()
i = j = 1
while i <= len(t) and j <= len(t):
	if t[i - 1] != s[j - 1]:
		i += 1
	else:
		i += 1
		j += 1
print(j)


s = input()
t = input()
j = 0
for i in range(len(t)):
	j += 1 if s[j] == t[i] else 0
print(j + 1)


col = input()
command = input()
i = 0
for c in command:
	if c == col[i]:
		i += 1
print(i + 1)


s = input()
t = input()
position = 0
for i in t:
	if s[position] == i:
		position += 1
print(position + 1)


Y = input()
I = input()
x = 0
for i in I:
	if i == Y[x]:
		x += 1
print(x + 1)


a = input()
c = input()
i = 0
j = 0
while i < len(c):
	if a[j] == c[i]:
		j = j + 1
	i = i + 1
print(j + 1)


s = input()
x = input()
count = 0
for i in range(len(x)):
	if x[i] == s[count]:
		count += 1
print(count + 1)


s = input()
t = input()
counter = 0
for c in range(len(t)):
	if t[c] == s[counter]:
		counter += 1
print(counter + 1)


s = input()
t = input()
pos = 1
initial = 0
for i in range(len(t)):
	if t[i] == s[initial]:
		pos += 1
		initial += 1
print(pos)


s1 = input()
s2 = input()
i = 0
j = 0
while j != len(s2):
	if s1[i] == s2[j]:
		i += 1
	j += 1
print(i + 1)


s1 = input()
s2 = input()
l1 = list(map(str, s1))
l2 = list(map(str, s2))
i = 0
c = 0
while i < len(l2):
	if l2[i] == l1[c]:
		i += 1
		c += 1
	else:
		i += 1
print(c + 1)


a = list(input())
b = list(input())
check = 0
for i in range(len(b)):
	if b[i] == a[check]:
		check += 1
print(check + 1)


s = input()
order = input()
p = 0
for i in range(len(order)):
	if p < len(s) and s[p] == order[i]:
		p += 1
print(p + 1)


def liss_stones(s, t):
	p = 0
	for i in range(len(t)):
		if t[i] == s[p]:
			p += 1
	return p + 1
s = input().strip()
t = input().strip()
print(liss_stones(s, t))


def colourful_stones(s, t):
	pos = 1
	temp = s[0]
	temp_pos = 0
	for i in range(len(t)):
		if temp == t[i]:
			pos = pos + 1
			temp_pos = temp_pos + 1
			temp = s[temp_pos]
		else:
			temp = s[temp_pos]
	print(pos)
s = input('')
t = input('')
colourful_stones(list(s), list(t))


s = input()
t = input()
pos = 0
for i in t:
	if i == s[pos]:
		pos += 1
print(pos + 1)


s = input()
t = input()
v = 0
for c in t:
	if c == s[v]:
		v += 1
print(v + 1)


s1 = input()
s2 = input()
c = 0
for i in range(len(s2)):
	if s2[i] == s1[c]:
		c += 1
	else:
		continue
print(c + 1)


s = list(input())
t = list(input())
position = 1
j = 0
for i in range(0, len(t)):
	if s[j] == t[i]:
		position = position + 1
		j = j + 1
print(position)


x = input()
x = list(x)
y = input()
y = list(y)
n = 0
s = 0
for i in y:
	if x[n] == y[s]:
		n = n + 1
	elif x[n] != y[s]:
		n = n + 0
	s = s + 1
print(n + 1)


s = input()
t = input()
i = 0
j = 0
while j < len(s) and i < len(t):
	for i in range(len(t)):
		if t[i] == s[j]:
			j += 1
	if i == len(t) - 1:
		break
print(j + 1)


s = input()
ins = input()
step = 0
place = 1
for command in ins:
	if s[step] == command:
		place += 1
		step += 1
print(place)


s = input()
t = input()
len2 = len(t)
i = 0
j = 0
while j != len2:
	if s[i] == t[j]:
		i += 1
	j += 1
print(i + 1)


s = input()
t = input()
cnt = 1
for i in t:
	if i == s[cnt - 1]:
		cnt += 1
ans = str(cnt)
print(ans)


x = input()
l = []
for i in x:
	l.append(i)
q = input()
i = 0
j = 0
while i < len(q):
	if q[i] == l[j]:
		j += 1
		i += 1
	else:
		i += 1
print(j + 1)


str1 = input()
str2 = input()
stones = list(str1)
dis = list(str2)
x = 0
for i in range(0, len(dis)):
	if stones[x] == dis[i]:
		x += 1
print(x + 1)


s = input()
t = input()
sp = 0
tp = 0
while tp < len(t):
	if s[sp] == t[tp]:
		sp += 1
		tp += 1
	else:
		tp += 1
print(sp + 1)


from sys import stdin
s = stdin.readline()[:-1]
t = stdin.readline()
i = 0
for j in t:
	if s[i] == j:
		i += 1
print(i + 1)


import sys
from math import sqrt, floor, factorial
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	s = inp()
	r = inp()
	ans = 1
	j = 0
	for i in range(len(r)):
		if s[j] == r[i]:
			j += 1
			ans += 1
	print(ans)
solve()


a = input().strip()
b = input().strip()
g = 0
for i in b:
	if i == a[g]:
		g += 1
print(g + 1)


stones = input()
commands = input()
stone_idx = 0
for c in commands:
	if stones[stone_idx] == c:
		stone_idx += 1
print(stone_idx + 1)


s = list(input())
t = list(input())
c = 1
for i in t:
	if i == s[c - 1]:
		c += 1
print(c)


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	s = st()
	t = st()
	i = 0
	j = 0
	while j < len(t):
		i += t[j] == s[i]
		j += 1
	pr(i + 1)
for _ in range(1):
	solve()


a = input()
pos = 0
for i in input():
	if i == a[pos]:
		pos += 1
print(pos + 1)


s = input()
t = input()
count = 0
i = 0
for j in t:
	if s[i] == j:
		i += 1
print(i + 1)


(s, t) = (input(), input())
(i, j, count) = (0, 0, 1)
while j < len(t):
	if s[i] == t[j]:
		i += 1
		j += 1
		count += 1
	else:
		j += 1
print(count)


s = input()
t = input()
ans = 1
j = 0
for _ in range(len(t)):
	if s[j] == t[_]:
		j += 1
		ans += 1
print(ans)


a = input()
b = input()
j = 0
s = 1
for i in range(len(b)):
	if b[i] == a[j]:
		s = s + 1
		j = j + 1
print(s)


def move(string, instructions):
	position = 0
	for i in instructions:
		if string[position] == i:
			position += 1
	return position + 1
string = str(input())
instructions = str(input())
print(move(string, instructions))


pos = input()
inst = input()
i = 0
for x in inst:
	if pos[i] == x:
		i += 1
print(i + 1)


import sys
input = sys.stdin.readlines()
path = []
path_str = input[0]
for p in path_str:
	path.append(p)
instructions = input[1]
position = 1
for move in instructions:
	if move == path[position - 1]:
		position += 1
print(position)


s = input()
t = input()
k = 0
for i in t:
	if i == s[k]:
		k += 1
print(k + 1)


def lf(n):
	c = 0
	while n > 0:
		if n % 10 == 4 or n % 10 == 7:
			c += 1
		n = n // 10
	return c

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
a = input()
b = input()
a = list(a)
b = list(b)
count = 0
for i in range(len(b)):
	if count + 1 == len(a):
		break
	if a[count] == b[i]:
		count += 1
print(count + 1)


s = input()
t = input()
i = 0
c = 0
j = 0
while True:
	if t[i] == s[j]:
		c = c + 1
		j = j + 1
	i = i + 1
	if i == len(t):
		break
print(c + 1)


s = input()
t = input()
ind = 0
for t1 in range(len(t)):
	if s[ind] == t[t1]:
		ind += 1
print(ind + 1)


s = input()
a = input()
ans = 0
for i in range(len(a)):
	if a[i] == s[ans]:
		ans += 1
print(ans + 1)


s = input().upper()
t = input().upper()
final = 0
for letter in t:
	if s[final] == letter:
		final += 1
print(final + 1)


a = input()
b = input()
a1 = 0
b1 = 0
while b1 <= len(b) - 1:
	if a[a1] == b[b1] and (not a1 == len(a) - 1):
		a1 += 1
	elif a[a1] == b[b1] and a1 == len(a) - 1:
		a1 = 0
	b1 += 1
print(a1 + 1)


from functools import lru_cache, wraps
from sys import stderr
import time
INF = 10 ** 18 + 3
EPS = 1e-10

def main():
	s = input()
	t = input()
	curr = 0
	for el in t:
		if s[curr] == el:
			curr += 1
	print(curr + 1)

@lru_cache(10 ** 9)
def find_perm(length, n_different):
	if length == 0:
		return []
	if n_different != length - 1:
		return list(range_of_len(length, length - n_different - 1, -1)) + find_perm(n_different + 1, n_different)
	curr = length
	go_down = True
	res = []
	for _ in range(n_different + 1):
		res.append(curr)
		curr = length - curr + go_down
		go_down ^= True
	return res

def res_to_stderr(function):

	def wrapped(*args, **kwargs):
		res = function(*args, **kwargs)
		print(res, file=stderr)
		return res
	return wrapped

def time_it(function, output=stderr):

	def wrapped(*args, **kwargs):
		start = time.time()
		res = function(*args, **kwargs)
		elapsed_time = time.time() - start
		print('Function "%s" took %f ms' % (function.__name__, elapsed_time * 1000), file=output)
		return res
	return wrapped

@res_to_stderr
def range_of_len(start, length, step=1):
	return range(start, start + length * step, step)

def set_input(file):
	global input
	input = lambda : file.readline().strip()

def set_output(file):
	global print
	l_print = print

	def print(*args, **kwargs):
		kwargs['file'] = kwargs.get('file', file)
		return l_print(*args, **kwargs)
time_it(main)()


def main():
	c = input()
	t = input()
	cur = 0
	for s in t:
		if c[cur] == s:
			cur += 1
	print(cur + 1)
main()


f = input()
s = input()
fc = 0
tc = 0
while tc != len(s):
	if s[tc] == f[fc]:
		fc += 1
	tc += 1
print(fc + 1)


stones = list(input())
stoneInstructions = list(input())
x = 0
stoneCount = 1
for i in range(len(stoneInstructions)):
	if stoneInstructions[i] == stones[x]:
		stoneCount += 1
		x += 1
	else:
		pass
print(str(stoneCount))


S = input()
T = input()
L = 1
for I in range(len(S)):
	Q = T.find(S[I])
	if Q != -1 and T != '':
		L += 1
		T = T[Q + 1:]
	else:
		break
print(L)


s = input()
instruct = input()
(n, i, j) = (len(instruct), 0, 0)
while j < n:
	if s[i] == instruct[j]:
		i += 1
		j += 1
	else:
		j += 1
print(i + 1)


a = input()
b = input()
c = 1
for x in range(len(b)):
	if b[x] == a[c - 1]:
		c += 1
print(c)


l = list(input())
l1 = list(input())
ans = 0
for i in range(len(l1)):
	if l1[i] == l[ans]:
		ans += 1
print(ans + 1)


colors = input()
moves = input()
index = 0
for m in moves:
	if m == colors[index]:
		index += 1
print(index + 1)


s1 = input()
s2 = input()
j = 0
for i in range(len(s2)):
	if s2[i] == s1[j]:
		j = j + 1
print(j + 1)


str1 = input()
str2 = input()
j = 0
key = str1[0:1]
for i in range(len(str2)):
	if key == str2[i:i + 1]:
		j += 1
		if j == len(str1):
			break
		key = str1[j:j + 1]
print(j + 1)


s = input()
a = list(s)
t = input()
b = list(t)
g = 0
for i in range(len(b)):
	if a[g] == b[i]:
		g += 1
print(g + 1)


s = list(input().strip())
t = list(input().strip())
n = 0
for letter in t:
	if letter == s[n]:
		n += 1
print(n + 1)


s = input()
t = input()
l = 0
for i in t:
	if i == s[l]:
		l += 1
print(l + 1)


s = str(input())
t = str(input())
count = 0
for i in range(len(t)):
	if t[i] == s[count]:
		count += 1
print(count + 1)


import sys
from functools import reduce
from collections import Counter
import time
import datetime
import math

def ip():
	return int(sys.stdin.readline())

def sip():
	return sys.stdin.readline()

def mip():
	return map(int, sys.stdin.readline().split())

def mips():
	return map(str, sys.stdin.readline().split())

def lip():
	return list(map(int, sys.stdin.readline().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.insert(i, arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
s1 = sip()
s2 = sip()
count = 1
i = 0
j = 0
while j < len(s2) - 1 and i < len(s1) - 1:
	if s1[i] == s2[j]:
		i += 1
		j += 1
		count += 1
	else:
		j += 1
if i == len(s1) - 1:
	print(count - 1)
else:
	print(count)


a = input()
b = input()
c = 0
for i in range(len(b)):
	if a[c] == b[i]:
		c = c + 1
print(c + 1)


s = input()
t = input()
pos = 0
count = 0
for inst in t:
	if inst == s[pos]:
		pos += 1
pos += 1
print(pos)


s = input()
s1 = input()
f = 0
pos = 0
for i in s1:
	if i == s[f]:
		f = f + 1
		pos = pos + 1
print(pos + 1)


def getPosition(path, instructions):
	pos = 0
	for i in range(max(len(path), len(instructions))):
		if i >= len(instructions) or pos >= len(path) - 1:
			break
		if path[pos] == instructions[i]:
			pos += 1
	return pos + 1
path = input()
instructions = input()
print(getPosition(path, instructions))


positions = input()
instr = input()
pos = 0
for i in range(len(instr)):
	if instr[i] == positions[pos]:
		pos += 1
print(pos + 1)


l = input()
l = list(l)
k = input()
k = list(k)
u = 0
for i in range(len(k)):
	if k[i] == l[u]:
		u = u + 1
print(u + 1)


a = input()
b = input()
i = 0
j = 0
n = len(b)
while True:
	if j < n and a[i] == b[j]:
		i = i + 1
	elif j == n:
		print(i + 1)
		exit()
	else:
		pass
	j = j + 1


s = input()
t = input()
moves = 1
sn = []
tn = []
for item in s:
	sn.append(ord(item))
for item in t:
	tn.append(ord(item))
i = 0
while i < len(tn):
	for item in tn:
		if item == sn[i]:
			moves += 1
			i += 1
		else:
			pass
	break
print(moves)


a = input()
b = input()
count = 0
n = 0
for i in range(count, len(a)):
	for j in range(n, len(b)):
		if a[i] == b[j]:
			count += 1
			n += 1
			break
		else:
			n += 1
print(count + 1)


n = input()
s = input()
b = []
a = []
x = 0
for i in range(len(n)):
	b.append(n[i])
for i in range(len(s)):
	a.append(s[i])
for i in range(len(b)):
	for j in range(len(a)):
		if b[i] == a[j]:
			b[i] = 0
			a[j] = 0
			break
		else:
			a[j] = 0
for i in range(len(b)):
	if b[i] == 0:
		x += 1
print(x + 1)


S = input()
T = input()
step = 0
for i in T:
	if i == S[step]:
		step += 1
print(step + 1)


l = input()
k = input()
liss = 1
j = 0
for i in range(len(k)):
	if l[j] == k[i]:
		liss += 1
		j += 1
print(liss)


s = input()
s1 = input()
s = list(s)
s1 = list(s1)
temp = 0
for i in s1:
	if i == s[temp]:
		temp += 1
print(temp + 1)


s = input()
ts = input()
pos = 0
for t in ts:
	if t == s[pos]:
		pos += 1
print(pos + 1)


s = input()
t = input()
pos = 0
for c in t:
	if c == s[pos]:
		pos += 1
print(pos + 1)


l = list(input())
ins = list(input())
i = 1
while ins:
	if l[0] == ins[0]:
		i = i + 1
		l.pop(0)
		ins.pop(0)
	else:
		ins.pop(0)
print(i)


(stones, instructions) = (input().strip(), input().strip())
pos = 1
for i in range(len(instructions)):
	if stones[pos - 1] == instructions[i]:
		pos += 1
print(pos)


s = input()
t = input()
count = 1
for i in t:
	if s[count - 1] == i:
		count = count + 1
print(count)


a = list(input())
s = list(input())
r = 1
for i in a:
	if i in s:
		q = s.index(i)
		del s[:q + 1]
		r += 1
	else:
		break
print(r)


s = input()
t = input()
c = 1
for i in range(len(t)):
	if s[c - 1] == t[i]:
		c = c + 1
print(c)


inp = list(input())
chec = list(input())
tot = 1
i = 0
for j in range(0, len(chec)):
	if chec[j] == inp[i]:
		tot = tot + 1
		i = i + 1
print(tot)


s = input()
ins = input()
i = 0
for j in range(len(ins)):
	if ins[j] == s[i]:
		i += 1
print(i + 1)


string_one = input()
instructions = input()
index = 0
for x in instructions:
	if x == string_one[index]:
		index += 1
	if index == len(string_one):
		break
print(index + 1)


stones = input()
instructions = input()
(idx1, idx2) = (0, 0)
while idx2 < len(instructions):
	if stones[idx1] == instructions[idx2]:
		idx1 += 1
	idx2 += 1
print(idx1 + 1)


str1 = list(input())
str2 = list(input())
j = 0
for i in str2:
	if i == str1[j]:
		j += 1
print(j + 1)


a = input()
b = input()
position = 0
for c in b:
	if c == a[position]:
		position += 1
print(position + 1)


x = input()
y = input()
ans = 1
p = 0
for i in y:
	if x[p] == i:
		ans += 1
		p += 1
print(ans)


import sys
from math import ceil, log
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('Yes')

def NO():
	print('No')
INF = 10 ** 18
MOD = 10 ** 9 + 7
s = ri()
t = ri()
i = 0
for j in range(len(t)):
	if t[j] == s[i]:
		i += 1
print(i + 1)


n = input()
s = input()
output = 1
k = 0
for i in s:
	if i == n[k]:
		output += 1
		k += 1
print(output)


x = input()
y = input()
a = 1
for i in y:
	if i == x[a - 1]:
		a += 1
print(a)


str1 = input()
str2 = input()
cpos = 0
for i in str2:
	if i == str1[cpos]:
		cpos += 1
print(cpos + 1)


s = input()
t = input()
j = 0
for i in t:
	j += i == s[j]
print(j + 1)


stone = input()
t = input()
c = 1
a = stone[c - 1]
for j in range(len(t)):
	if a == t[j]:
		c += 1
		a = stone[c - 1]
print(c)


from collections import deque
from math import log, sqrt, ceil

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())
s = si()
t = si()
l = 0
for i in range(len(t)):
	if t[i] == s[l]:
		l += 1
print(l + 1)


stones = input()
instructions = input()
num_instructions = len(instructions)
pointer = 0
n = 0
while pointer != num_instructions:
	if stones[n] == instructions[pointer]:
		n += 1
		pointer += 1
		continue
	pointer += 1
print(n + 1)


l = [y for y in input()]
o = [y for y in input()]
count = 1
for x in o:
	if l[count - 1] == x:
		count = count + 1
print(count)


(a, b) = (input(), input())
(i, j) = (0, 0)
while True:
	while j < len(b) and a[i] != b[j]:
		j += 1
	if j == len(b):
		break
	i += 1
	j += 1
print(i + 1)


(s, i) = (input(), 0)
for ch in input():
	if s[i] == ch:
		i += 1
print(i + 1)


string = input()
stringg = input()
e = 0
for i in stringg:
	if i == string[e]:
		e = e + 1
print(e + 1)


def main():
	stones = input()
	instructions = input()
	n_stones = len(stones)
	n_instructions = len(instructions)
	stones_index = 0
	instructions_index = 0
	while instructions_index < n_instructions:
		try:
			instructions_index = next((i for i in range(instructions_index, n_instructions) if instructions[i] == stones[stones_index]))
			stones_index += 1
			instructions_index += 1
		except StopIteration:
			break
	print(stones_index + 1)
main()


s = input()
s0 = input()
j = 0
for i in s0:
	if s[j] == i:
		j += 1
print(j + 1)


s = input()
t = input()
c = 0
for instruction in t:
	if instruction == s[c]:
		c += 1
print(c + 1)


(s, c, p) = (list(input()), input(), 1)
for i in c:
	if i == s[0]:
		s.pop(0)
		p += 1
print(p)


s = input()
p = input()
j = 0
for i in p:
	if s[j] == i:
		j += 1
print(j + 1)


import sys
a = input()
b = input()
m = len(b)
i = 0
j = 0
c = 0
while int(i) < int(m):
	if a[j] == b[i]:
		c += 1
		j += 1
	i += 1
print(j + 1)


S = input()
t = input()
ind = 0
for i in range(len(t)):
	if t[i] == S[ind]:
		ind += 1
print(ind + 1)


way = input()
instruct = input()
pos = 1
for i in instruct:
	if way[pos - 1] == i:
		pos += 1
print(pos)


s = str(input())
t = str(input())
i = 0
for j in t:
	if j == s[i]:
		i = i + 1
print(i + 1)


n = list(input())
p = list(input())
y = 0
for x in range(len(p)):
	if p[x] == n[y]:
		y += 1
	else:
		pass
print(y + 1)


def solve():
	s = input()
	c = input()
	move = 0
	for i_c in range(len(c)):
		if c[i_c] == s[move]:
			move += 1
	print(move + 1)
solve()


s = input()
t = input()
(l1, l2) = (len(s), len(t))
(i, j, count) = (0, 0, 1)
while i < l1 and j < l2:
	if s[i] == t[j]:
		i += 1
		j += 1
		count += 1
	else:
		j += 1
print(count)


li = list(input())
li2 = list(input())
count = 0
i = 0
while i < len(li2):
	if li[count] == li2[i]:
		count = count + 1
	i = i + 1
print(count + 1)


str_a = input()
str_b = input()
index = 0
for char in str_b:
	if char == str_a[index]:
		index += 1
print(index + 1)


stones = input()
instructions = input()
steps = 0
for i in instructions:
	if len(stones) >= 0 and stones[0] == i:
		steps += 1
		stones = stones[1:]
print(steps + 1)


s1 = input()
s2 = input()
j = 0
c = 0
for i in range(len(s2)):
	if j < len(s1) - 1:
		if s2[i] == s1[j]:
			c += 1
			j += 1
	else:
		break
print(j + 1)


s = input()
i = input()
p = 0
for x in i:
	if x == s[p]:
		p += 1
print(p + 1)


s = input()
t = input()
pos = 1
for i in t:
	if s[pos - 1] == i:
		pos += 1
	else:
		continue
print(pos)


s = input()
t = input()
k = 0
for x in t:
	if x == s[k]:
		k += 1
print(k + 1)


stones = input()
instructions = input()
answ = 1
curStoneIdx = 0
for i in range(len(instructions)):
	if stones[curStoneIdx] == instructions[i]:
		answ += 1
		curStoneIdx += 1
print(answ)


a = input()
b = input()
p = 0
for i in b:
	if p < len(a) and i == a[p]:
		p += 1
print(p + 1)


s = list(input())
t = list(input())
count_ = 0
for i in range(0, len(t)):
	if s[count_] == t[i]:
		count_ += 1
	else:
		continue
print(count_ + 1)


import sys

def i():
	return input()

def ii():
	return int(input())

def li():
	return input().split()

def mi():
	return list(map(int, input().split()))
s = i()
t = i()
cp = 0
for i in t:
	if i == s[cp]:
		cp += 1
print(cp + 1)


a = [x for x in input()]
b = [x for x in input()]
ans = 0
for i in b:
	if a[ans] == i:
		ans += 1
print(ans + 1)


a = input()
b = input()
pos = 0
ans = 0
for i in b:
	if i == a[pos]:
		ans += 1
		pos += 1
		if pos >= len(a):
			break
print(ans + 1)


s = input()
g = input()
pos = 0
cur = 0
while cur < len(s) and pos < len(g):
	if s[cur] == g[pos]:
		pos += 1
		cur += 1
	else:
		pos += 1
print(cur + 1)


s = input()
t = input()
p = 0
for i in t:
	if s[p] == i:
		p += 1
print(p + 1)


stones = input()
instr = input()
steps = 1
for t in instr:
	if t == stones[steps - 1]:
		steps += 1
print(steps)


s = str(input())
t = str(input())
lv = 0
for i in t:
	if i == s[lv]:
		lv += 1
print(lv + 1)


s = list(input())
t = list(input())
pos = 1
for i in range(len(t)):
	if s[pos - 1] == t[i]:
		pos += 1
print(pos)


inp = list(input())
ins = list(input())
res = 0
for i in range(len(ins)):
	if inp[res] == ins[i]:
		res += 1
print(res + 1)


s = input()
t = input()
s_c = 0
for k in t:
	if k == s[s_c]:
		s_c += 1
print(s_c + 1)


stones = input()
instr = input()
curr = 0
for i in instr:
	if i == stones[curr]:
		curr += 1
print(curr + 1)


s = input()
t = input()
i = 0
j = 0
c = 0
val = len(t)
while val != 0:
	if t[i] == s[j]:
		i += 1
		j += 1
		c += 1
	else:
		i += 1
	val -= 1
print(c + 1)


s1 = input()
s2 = input()
i = j = 0
while i < len(s1) and j < len(s2):
	if s1[i] == s2[j]:
		i += 1
		j += 1
	else:
		j += 1
print(i + 1)


import sys
s = input()
t = input()
ans = 0
for i in range(len(t)):
	if t[i] == s[ans]:
		ans += 1
print(ans + 1)


n = input()
t = input()
c = 1
x = y = 0
mn = max(len(n), len(t))
while x < mn and y < mn:
	try:
		if n[x] == t[y]:
			c += 1
			x += 1
			y += 1
		else:
			y += 1
	except IndexError:
		break
print(c)


c = input()
t = input()
count = 1
k = 0
j = 0
for i in range(len(t)):
	if c[k] == t[j]:
		count += 1
		k += 1
	j += 1
print(count)


stones = list(input())
instructions = list(input())
position = 0
i = 0
for j in range(len(instructions)):
	if instructions[j] == stones[i]:
		i += 1
print(i + 1)


s = input()
t = input()
c = 1
for ch in t:
	if ch == s[c - 1]:
		c += 1
print(c)


x = input()
z = input()
m = 0
n = 0
e = 1
while m < len(x):
	while n < len(z):
		if x[m] == z[n]:
			e += 1
			n += 1
			break
		else:
			n += 1
	m += 1
print(e)


def main():
	way = input()
	i = 0
	for c in input():
		if c == way[i]:
			i += 1
	print(i + 1)

def __starting_point():
	main()
__starting_point()


s = input()
t = input()
inS = 0
inT = 0
for i in t:
	if i == s[inS]:
		inS += 1
print(inS + 1)


a = input()
b = input()
j = 0
for i in b:
	if i == a[j]:
		j += 1
print(j + 1)


from sys import stdin, stdout
input = stdin.readline

def write(n, sep='\n'):
	stdout.write(str(n))
	stdout.write(sep)

def gil():
	return list(map(int, input().split()))
s = input()
t = input()
x = 0
for i in range(len(t)):
	if s[x] == t[i]:
		x += 1
print(x + 1)


def main():
	stone = input()
	instructions = input()
	jump = 0
	count = 1
	for i in range(len(instructions)):
		if instructions[i] == stone[jump]:
			count += 1
			jump += 1
		if jump == len(stone):
			break
	print(count)
main()


s1 = input()
c = input()
m = 0
for i in range(len(c)):
	if s1[m] == c[i]:
		m += 1
print(m + 1)


s = input()
s1 = input()
d = 0
for i in s1:
	if s[d] == i:
		d += 1
print(d + 1)


s = input()
t = input()
pos = 0
for x in t:
	if x == s[pos]:
		pos += 1
print(pos + 1)


stones = str(input())
moves = str(input())
out = 0
for k in range(len(moves)):
	if moves[k] == stones[out]:
		out += 1
print(out + 1)


from math import *
from collections import *
from sys import *
t = stdin.readline
p = stdout.write

def gI():
	return map(int, t().strip().split())

def gS():
	return map(str, t().strip().split())

def gL():
	return list(map(int, t().strip().split()))

def SL():
	return list(map(str, t().strip().split()))
s = [i for i in SL()[0]]
t = [i for i in SL()[0]]
(c1, c2) = (0, 0)
while c1 < len(s) and c2 < len(t):
	if s[c1] == t[c2]:
		c1 += 1
		c2 += 1
	else:
		c2 += 1
print(c1 + 1)


n = str(input())
t = str(input())
pos = 0
for i in range(len(t)):
	if t[i] == n[pos]:
		pos = pos + 1
print(pos + 1)


A = input()
B = input()
(n, m, count) = ([], [], 0)
pos = 0
for i in range(len(B)):
	if B[i] == A[pos]:
		pos += 1
print(pos + 1)


seq = input()
instructions = input()
iterator = 0
count = 1
for i in instructions:
	if i == seq[iterator]:
		count += 1
		iterator += 1
print(count)


snts = input()
cmds = input()
i = 1
for each in cmds:
	if each == snts[i - 1]:
		i = i + 1
print(i)


x = input()
y = [i for i in input()]
counter = 0
for i in y:
	if x[counter] == i:
		counter += 1
print(counter + 1)


p = 0
l_s = input()
l_i = input()
for i in l_i:
	if i == l_s[p]:
		p += 1
		if p == len(l_s):
			break
print(p + 1)


from sys import stdin
s = stdin.readline().rstrip()
f = stdin.readline().rstrip()
i = 0
j = 0
while j < len(f):
	if s[i] == f[j]:
		i += 1
	j += 1
print(i + 1)


s = input()
t = input()
flag = 0
for i in t:
	if i == s[flag]:
		flag += 1
print(flag + 1)


s = input()
t = input()
output = 1
(i, j) = (0,) * 2
while i < len(s) and j < len(t):
	if s[i] == t[j]:
		i += 1
		j += 1
		output += 1
	else:
		j += 1
print(output)


str1 = str(input())
str2 = str(input())
n1 = len(str1)
n2 = len(str2)
pos = 1
i = 0
while i < n2:
	if str2[i] == str1[pos - 1]:
		pos += 1
	i += 1
print(pos)


s = input()
t = input()
ind = 0
ch = s[ind]
counter = 0
newStr = s[ind]
for i in range(0, len(t)):
	if s[ind] == t[i]:
		newStr = s[ind + 1]
		ind += 1
		counter += 1
print(counter + 1)


s = input()
n = input()
b = 0
a = s[b]
for i in n:
	if i is a:
		b += 1
		a = s[b]
print(b + 1)


def stones(s, t):
	j = 0
	for i in range(len(s)):
		if s[i] == t[j]:
			j += 1
	return j + 1
a = input()
b = input()
print(stones(b, a))


s = list(input())
t = list(input())
l = 1
for i in t:
	l += 1 if i == s[l - 1] else 0
print(l)


path = list(input())
inst = list(input())
cnt = 1
while len(inst):
	if path[0] == inst[0]:
		cnt += 1
		path.pop(0)
	inst.pop(0)
print(cnt)


(colour, instructions) = (input(), input())
position = 1
for i in instructions:
	if i == colour[position - 1]:
		position += 1
print(position)


s = input()
t = input()
s1 = [i for i in s]
s2 = [j for j in t]
count = 0
i = 0
for k in range(len(s2)):
	if s2[k] == s1[i]:
		i += 1
		count += 1
print(count + 1)


s = input()
t = input()
Liss = 1
i = 0
j = 0
while j < len(t):
	if s[i] == t[j]:
		Liss += 1
		i += 1
	j += 1
print(Liss)


s = input()
t = input()
a = list(s)
b = list(t)
m = a[0]
c = 0
for i in range(len(b)):
	if m == b[i]:
		c = c + 1
		m = a[c]
print(c + 1)


s = input()
t = input()
a = len(t)
b = 0
for x in range(a):
	if s[b] == t[x]:
		b += 1
print(b + 1)


stones = input('')
instructions = input('')
stone_position = 0
for c in instructions:
	if c == stones[stone_position]:
		stone_position += 1
print(stone_position + 1)


word = input()
reference = input()
count = 0
for item in reference:
	if item == word[count]:
		count += 1
print(count + 1)


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def def_value():
	return 0
s = input()
a = input()
p = 0
for i in a:
	if i == s[p]:
		p += 1
print(p + 1)


n = input()
n1 = input()
v = 0
for i in range(len(n1)):
	l = n[v]
	if l == n1[i]:
		v = v + 1
print(v + 1)


from collections import Counter

def solve():
	str1 = input()
	str2 = input()
	(count, j) = (1, 0)
	for i in range(len(str2)):
		if str1[j] == str2[i]:
			count += 1
			j += 1
	return count
print(solve())


line = input()
instructions = input()
j = 0
count = 1
for i in range(len(instructions)):
	if instructions[i] == line[j]:
		count += 1
		j += 1
print(count)


seq = list(input())
test_sequence = list(input())
i = 0
for color in test_sequence:
	if color == seq[i]:
		i += 1
print(i + 1)


stones = input()
inst = input()
sq = 0
for i in range(len(inst)):
	if inst[i] == stones[sq]:
		sq += 1
print(sq + 1)


s = input()
s2 = input()
step = 0
for i in range(len(s2)):
	if s2[i] == s[step]:
		step += 1
print(step + 1)


s1 = input()
s2 = input()
res = 1
for i in range(len(s2)):
	if s2[i] == s1[res - 1]:
		res += 1
print(res)


stringInput = input()
instructions = input()
output = 0
for i in range(len(instructions)):
	if instructions[i] == stringInput[output]:
		output += 1
print(output + 1)


def ii():
	return int(input())

def ss():
	return [x for x in input()]

def si():
	return [int(x) for x in input().split()]

def mi():
	return map(int, input().split())
a = input()
b = input()
ans = 0
for i in b:
	if a[ans] == i:
		ans += 1
print(ans + 1)


a = input()
b = input()
l = 0
for i in b:
	if i == a[l]:
		l += 1
print(l + 1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	s = S()
	t = S()
	i = 0
	for x in t:
		if s[i] == x:
			i += 1
	return i + 1
print(main())


color = input()
instruction = list(input())
position = 0
for inst in instruction:
	if inst == color[position]:
		position += 1
print(position + 1)


p = input()
c = input()
y = 0
for i in range(len(c)):
	if c[i] == p[y]:
		y += 1
print(y + 1)


import sys

class TailRecurseException(BaseException):

	def __init__(self, args, kwargs):
		self.args = args
		self.kwargs = kwargs

def tail_call_optimized(g):

	def func(*args, **kwargs):
		f = sys._getframe()
		if f.f_back and f.f_back.f_back and (f.f_back.f_back.f_code == f.f_code):
			raise TailRecurseException(args, kwargs)
		else:
			while 1:
				try:
					return g(*args, **kwargs)
				except TailRecurseException as e:
					args = e.args
					kwargs = e.kwargs
	func.__doc__ = g.__doc__
	return func

def solve(*, t: str, s: str) -> int:

	@tail_call_optimized
	def wrapper(*, _t: str, _s: str, _indx: int, _pos: int) -> int:
		if _indx == len(_s):
			return _pos
		if _t[_pos] == _s[_indx]:
			return wrapper(_t=_t, _s=_s, _indx=_indx + 1, _pos=_pos + 1)
		return wrapper(_t=_t, _s=_s, _indx=_indx + 1, _pos=_pos)
	return wrapper(_t=t, _s=s, _indx=0, _pos=0)
t = input()
s = input()
result = solve(t=t, s=s) + 1
print(result)


b = 1
z = list(map(str, input()))
x = list(map(str, input()))
for c in z:
	for v in range(len(x)):
		if c == x[0]:
			b = b + 1
		m = x[0]
		x.remove(x[0])
		if c == m:
			break
print(b)


stones = input()
instructions = input()
index = 0
for i in range(len(instructions)):
	if instructions[i] == stones[index]:
		index += 1
print(index + 1)


k = input()
n = iter(input())
i = 0
while True:
	try:
		if k[i] == next(n):
			i = i + 1
	except:
		print(i + 1)
		break


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
s = input()
t = input()
pos = 0
for i in range(len(t)):
	if t[i] == s[pos]:
		pos += 1
print(pos + 1)


s1 = input()
s2 = input()
pos = 0
for ch in s2:
	if s1[pos] == ch:
		pos += 1
		if pos == len(s1):
			break
print(pos + 1)


RO = input()
ins = input()
n = 0
for x in range(len(ins)):
	if ins[x] == RO[n]:
		n += 1
print(n + 1)


def stones(lista):
	index = 0
	for i in lista[1]:
		if i == lista[0][index]:
			index += 1
	return index + 1
x = input()
y = input()
inp = [x, y]
print(stones(inp))


stone = input()
instr = input()
viTri = 1
for i in range(0, len(instr)):
	if instr[i] == stone[0]:
		viTri += 1
		stone = stone[1:]
	else:
		continue
print(viTri)


def int_lst_input():
	return [int(val) for val in input().split(' ')]

def int_input():
	return int(input())

def print_lst(lst):
	print(' '.join([str(val) for val in lst]))

def solve():
	s = input()
	t = input()
	j = 0
	for i in range(len(t)):
		if t[i] == s[j]:
			j += 1
	print(j + 1)
solve()


s1 = input()
s2 = input()
i = 0
j = 0
lns1 = len(s1)
lns2 = len(s2)
while j < lns2:
	if s1[i] == s2[j]:
		i += 1
	j += 1
print(i + 1)


s = input()
t = input()
c = 0
for i in t:
	if s[c] == i:
		c += 1
print(c + 1)


colors = input()
instructions = input()
pointer = 0
for index in range(len(instructions)):
	if instructions[index] == colors[pointer]:
		pointer += 1
print(pointer + 1)


s = input()
t = input()
flg = -1
count = 1
for i in t:
	flg += 1
	if i == s[flg]:
		count += 1
	else:
		flg -= 1
print(count)


s = input()
t = input()
count = 1
for i in range(len(s)):
	if s[i] not in t:
		break
	for j in range(len(t)):
		if t[j] == s[i]:
			count += 1
			t = t[j + 1:]
			break
print(count)


stones = input()
com = input()
pos = 1
st = 0
while True:
	for instruction in com:
		if instruction == stones[st]:
			pos += 1
			st += 1
			continue
	else:
		break
print(pos)


s = input()
t = input()
p = 0
cnt = 0
i = 0
u = 0
while i < len(t):
	if s[u] == t[p]:
		p += 1
		u += 1
		cnt += 1
	else:
		p += 1
	i += 1
print(cnt + 1)


s = str(input())
t = str(input())
idx = 0
ans = s[idx]
for i in range(len(t)):
	if ans == t[i]:
		idx += 1
		ans = s[idx]
print(idx + 1)


x = input()
y = input()
counter = 1
j = 0
for letters in range(len(y)):
	if x[j] == y[letters]:
		counter += 1
		j += 1
	else:
		continue
print(counter)


way = list(input())
instructions = list(input())
x = 0
y = 0
location = 1
while True:
	if len(instructions) == 0:
		break
	elif way[x] == instructions[y]:
		location += 1
		way = way[x + 1:]
		instructions = instructions[y + 1:]
		y = 0
	else:
		instructions = instructions[y + 1:]
print(location)


def final_position(positions, instructions):
	current_pos = 0
	for instruction in instructions:
		if instruction == positions[current_pos]:
			current_pos += 1
	return current_pos + 1
positions = input()
instructions = input()
print(final_position(positions, instructions))


try:
	f = input()
	s = input()
	i = 0
	j = 0
	count = 0
	while i != len(s):
		if s[i] == f[j]:
			i = i + 1
			j = j + 1
			count = count + 1
		else:
			i = i + 1
	print(count + 1)
except:
	pass


s = input()
i = input()
prev = i[0]
pos = 1
l = len(i)
for j in range(1, l):
	if s[pos - 1] == prev:
		pos += 1
	prev = i[j]
if prev == s[pos - 1]:
	pos += 1
print(pos)


s = input()
ins = input()
pos = 0
for i in ins:
	if s[pos] == i:
		pos += 1
print(pos + 1)


s = input()
c = input()
i = 0
while s[i] in c:
	c = c[c.index(s[i]) + 1:]
	i += 1
print(i + 1)


standing = input()
inst = input()
standing_on = 0
for char in inst:
	if char == standing[standing_on]:
		standing_on += 1
print(standing_on + 1)


try:
	s1 = input()
	s2 = input()
	(i, j) = (0, 0)
	count = 1
	while i < len(s1) and j < len(s2):
		if s1[i] == s2[j]:
			count += 1
			i = i + 1
			j = j + 1
		else:
			j = j + 1
	print(count)
except Exception:
	pass


s = input()
t = input()
p = 0
while t:
	if s[p] == t[0]:
		p += 1
	t = t[1:]
print(p + 1)


s = input()
t = list(input())
move = 1
i = 0
while t:
	if t[0] == s[i]:
		move += 1
		i += 1
	t.pop(0)
print(move)


ans = 0
t = list(input())
c = list(input())
for i in range(len(c)):
	if c[i] == t[ans]:
		ans = ans + 1
print(ans + 1)


s = input()
moves = input()
pos = 0
for c in moves:
	if c == s[pos]:
		pos += 1
print(pos + 1)


(s, i) = (input(), 0)
for x in input():
	i += x == s[i]
print(i + 1)


from __future__ import division, print_function
import sys
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	s1 = sin()
	s2 = sin()
	s1 = list(s1)
	s2 = list(s2)
	temp = 0
	for i in range(len(s2)):
		if s1[temp] == s2[i]:
			temp += 1
	print(temp + 1)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


s = list(input())
t = list(input())
sc = 0
for i in t:
	if i == s[sc]:
		sc += 1
print(sc + 1)


n = input()
s = input()
i = 0
z = 0
while i <= len(n) - 1 and z <= len(s) - 1:
	if n[i] != s[z]:
		z = z + 1
	if z >= len(s):
		break
	if n[i] == s[z]:
		i = i + 1
		z = z + 1
	if z >= len(s):
		break
print(i + 1)


s = input()
t = input()
(k, j) = (0, 0)
while k < len(t):
	if j < len(s) and t[k] == s[j]:
		j += 1
	k += 1
print(j + 1)


s = input()
c = input()
ans = 0
for i in c:
	if i == s[ans]:
		ans += 1
print(ans + 1)


stones = input()
instructions = input()
pos = 0
for i in instructions:
	if i == stones[pos]:
		pos += 1
print(pos + 1)


from math import ceil, log, floor, sqrt
import math
k = 1

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def is_prime(n):
	m = 2
	while m * m <= n:
		if n % m == 0:
			return False
		m += 1
	return True

def find_sum(n, a):
	a.insert(0, 0)
	for i in range(1, n + 1):
		prev = a[i] & a[i - 1]
		cur = a[i] | a[i - 1]
		a[i - 1] = prev
		a[i] = cur
	return sum((m * m for m in a))

def prin_abc(x, y, z):
	l = [x, y, z]
	l.sort()
	if l[1] < l[2]:
		print('NO')
		return
	a = b = l[0]
	c = l[2]
	print('YES')
	print(a, b, c)

def get_scores(n, vals):
	l = 0
	r = n - 1
	turn = 0
	sereja = 0
	dima = 0
	while l <= r:
		if vals[l] > vals[r]:
			cur = vals[l]
			l += 1
		else:
			cur = vals[r]
			r -= 1
		if turn == 0:
			sereja += cur
		else:
			dima += cur
		turn = not turn
	print(sereja, dima)

def count_lamps(n, m):
	return (n * m + 1) // 2

def find_holidays(n):
	cnt = 2 * (n // 7)
	rem = n % 7
	mx = mn = cnt
	if rem == 1:
		mx += 1
	elif rem > 1:
		mx += 2
	if rem == 6:
		mn += 1
	print(mn, mx)

def find_pos(s, instruction):
	i = 0
	for c in instruction:
		if s[i] == c:
			i += 1
	return i + 1
t = 1
while t:
	t = t - 1
	(k, g) = (0, 0)
	points = []
	a = input()
	b = input()
	print(find_pos(a, b))


string = input()
command = input()
j = 0
for i in command:
	if i == string[j]:
		j = j + 1
print(j + 1)


a = input()
c = input()
pos = 0
for cmd in c:
	if cmd == a[pos]:
		pos += 1
print(pos + 1)


s = str(input())
t = str(input())
i = 0
j = 0
l = len(t)
while j < l:
	if s[i] == t[j]:
		i += 1
		j += 1
	else:
		j += 1
print(i + 1)


s1 = input()
s2 = input()
liss = 0
for i in range(len(s2)):
	if (s2[i] == s1[liss]) == True:
		liss += 1
print(liss + 1)


s = input()
k = input()
c = 1
i = 0
t = 1
while t <= len(k):
	if k[i] == s[c - 1]:
		c = c + 1
	t = t + 1
	i += 1
print(c)


str1 = input()
str2 = input()
ancor = 1
j = 0
for i in range(len(str1)):
	while j != len(str2):
		if str1[i] == str2[j]:
			ancor += 1
			j += 1
			break
		j += 1
print(ancor)


s = input()
q = input()
i = 1
for k in range(len(q)):
	if s[i - 1] == q[k]:
		i += 1
print(i)
print()


path = list(input())
commands = list(input())
pos = 1
while commands:
	if commands.pop(0) == path[0]:
		del path[0]
		pos += 1
print(pos)


def main():
	s = str(input())
	t = str(input())
	i = 0
	j = 0
	while j < len(t):
		if s[i] == t[j]:
			i += 1
		j += 1
	print(i + 1)
main()


def main():
	(s, l) = (input(), input())

	def number_of_stone_liss_standing_on(s, l):
		current_stone = 1
		for color in l:
			if color == s[current_stone - 1]:
				current_stone += 1
		return current_stone
	print(number_of_stone_liss_standing_on(s, l))
main()


s1 = input()
s2 = input()
res = 0
for i in s2:
	if s1[res] == i:
		res += 1
print(res + 1)


s = input()
t = input()
count = 0
for item in t:
	if item == s[count]:
		count += 1
print(count + 1)


(s, t) = (input(), input())
index = 0
for i in t:
	if i == s[index] and index < len(s) - 1:
		index += 1
print(index + 1)


s = input()
t = input()
res = 1
for (idx, c) in enumerate(t):
	if s[res - 1] == c:
		res += 1
print(res)


l1 = list(input())
l2 = list(input())
c = 0
for i in l2:
	if i == l1[c]:
		c += 1
	else:
		continue
print(c + 1)


x = input()
x2 = input()
p = 0
for i in range(len(x2)):
	if x2[i] == x[p]:
		p += 1
print(p + 1)


s = input()
t = input()
ans = 1
temp = s[0]
x = 1
for i in t:
	if i == temp:
		ans -= -1
		temp = s[x]
		x -= -1
print(ans)


s = input()
t = input()
n = len(s)
m = len(t)
count = 1
k = 0
for i in range(m):
	if s[k] == t[i]:
		count += 1
		k += 1
print(count)


s = input()
t = input()
index = 0
counter = 0
for i in range(len(t)):
	if s[index] == t[i]:
		index += 1
		counter += 1
print(counter + 1)


stones = input()
inst = input()
position = 1
for (i, letter) in enumerate(inst):
	if letter == stones[position - 1]:
		position += 1
print(position)


list1 = []
list1.append(input().strip().upper())
list1.append(input().strip().upper())
n = 1
for i in list1[1]:
	if i == list1[0][n - 1]:
		n += 1
print(n)


p = input()
t = input()
o = 0
y = 0
while True:
	try:
		if t[o] == p[y]:
			o += 1
			y += 1
		else:
			o += 1
	except:
		break
print(y + 1)


a = input()
b = input()
pnt = 1
for i in range(len(b)):
	if a[pnt - 1] == b[i]:
		pnt += 1
print(pnt)


s = list(input())
t = list(input())
k = 0
for i in range(len(t)):
	if t[i] == s[k]:
		k += 1
print(k + 1)


import sys
import math
import bisect

def main():
	s = input()
	t = input()
	pos = 0
	for c in t:
		if s[pos] == c:
			pos += 1
	print(pos + 1)
main()


s = input()
t = input()
a = 1
for i in range(len(t)):
	b = s[a - 1]
	if t[i] == b:
		a += 1
print(a)


a = input()
b = input()
start = a[0]
stone = 1
i = 0
j = 0
while i < len(a) and j < len(b):
	if a[i] == b[j]:
		stone += 1
		i += 1
		j += 1
	else:
		j += 1
print(stone)


s = input()
t = input()
a = 0
for i in t:
	if i == s[a]:
		a += 1
a += 1
print(a)


s = input()
c = input()
j = 0
for i in c:
	if s[j] == i:
		j += 1
print(j + 1)


s = input()
t = input()
pos = 1
i = 0
j = 0
while True:
	if s[i] == t[j]:
		pos = pos + 1
		i = i + 1
		j = j + 1
	else:
		j = j + 1
	if j >= len(t):
		break
print(pos)


a = str(input())
b = str(input())
n = 1
for i in range(len(b)):
	if a[n - 1] == b[i]:
		n = n + 1
print(n)


k = list(input())
n = input()
o = len(k)
[k.pop(0) for i in n if i == k[0]]
print(o - len(k) + 1)


s = input()
t = input()
k = 0
for i in t:
	if i == s[k]:
		k = k + 1
	else:
		continue
print(k + 1)


s = input()
i = input()
spot = 0
fatspot = 0
for j in range(len(i)):
	if i[j] == s[spot]:
		spot += 1
print(spot + 1)


l = input('')
t = input('')
currPos = 0
for i in t:
	if l[currPos] == i:
		currPos += 1
print(currPos + 1)


stone = input()
ins = input()
k = 0
for i in range(len(ins)):
	if ins[i] == stone[k]:
		k += 1
print(k + 1)


ground = input()
current_position = 0
instructions = input()
for i in instructions:
	if i is ground[current_position]:
		current_position += 1
print(current_position + 1)


def solve(stones, commands):
	cur = 0
	for i in commands:
		if i == stones[cur]:
			cur += 1
	return cur + 1
res = solve(input(), input())
print(res)


s = input()
t = input()
res = 0
for x in t:
	if s[res] == x:
		res += 1
print(res + 1)


s = input()
s1 = input()
c = 0
for i in s1:
	if s[c] == i:
		c += 1
print(c + 1)


a = input()
b = input()
c = 0
for i in b:
	if i == a[c]:
		c += 1
print(c + 1)


n = input()
m = input()
l = len(m)
a = 0
for i in range(l):
	if m[i] == n[a]:
		a += 1
print(a + 1)


a = input()
b = input()
t = 0
k = 0
for i in range(len(b)):
	if a[t] == b[i]:
		t += 1
		k += 1
print(k + 1)


stones = [i for i in input()]
instructions = [i for i in input()]
position = 0
for i in instructions:
	if i == stones[position]:
		position += 1
print(position + 1)


l = input()
s = input()
c = 1
n = len(l)
for i in s:
	if l[c - 1] == i:
		c += 1
	if c == n:
		break
print(c)


s = input()
t = input()
m = 0
for i in t:
	if s[m] == i:
		m += 1
print(m + 1)


x = input()
y = input()
ind = 0
counter = 0
for i in range(len(y)):
	if y[i] == x[ind]:
		counter += 1
		ind += 1
		continue
print(counter + 1)


stone_queue = input()
instruction_queue = input()
move = False
start_pos = 1
for i in range(1, len(instruction_queue) + 1):
	if stone_queue[start_pos - 1] == instruction_queue[i - 1]:
		start_pos += 1
print(start_pos)


a = input()
counter = 0
for c in input():
	counter += a[counter] == c
print(counter + 1)


m = input()
n = input()
s = 0
for i in range(len(n)):
	if n[i] == m[s]:
		s = s + 1
print(s + 1)


t = list(input())
s = list(input())
p = 0
for k in s:
	if k == t[p]:
		p += 1
print(p + 1)


x = input()
y = input()
z = 0
for i in y:
	if x[z] == i:
		z += 1
print(z + 1)


s = input()
i = input()
n = len(s)
m = len(i)
c = s[0]
j = 0
ans = 1
for k in i:
	if k == c:
		j += 1
		c = s[j]
		ans += 1
print(ans)


s = input()
q = input()
count = 0
j = 0
for i in range(len(q)):
	if s[j] == q[i]:
		count += 1
		j += 1
print(count + 1)


def solution(s, t):
	i = 0
	for x in t:
		if x == s[i]:
			i += 1
	return i + 1
s = input()
t = input()
print(solution(s, t))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	s = S() + 'x'
	t = S()
	r = 0
	for c in t:
		if s[r] == c:
			r += 1
	return r + 1
print(main())


s = str(input())
command = str(input())
pos = 1
for j in range(len(command)):
	if command[j] == s[pos - 1]:
		pos += 1
print(pos)


def answer():
	a = list(input())
	b = list(input())
	i = 0
	targ = a[0]
	j = 0
	while i < len(b):
		if targ == b[i]:
			j += 1
			targ = a[j]
		else:
			pass
		i += 1
	print(j + 1)
answer()


S = input()
T = input()
ind = 0
for t in T:
	if S[ind] == t:
		ind += 1
print(ind + 1)


n = list(input())
m = list(input())
ans = 0
for i in range(len(m)):
	if m[i] == n[ans]:
		ans += 1
print(ans + 1)


(stones, inst) = (input(), input())
position = 0
ins = 0
for i in range(len(inst)):
	if stones[ins] == inst[i]:
		position += 1
		ins += 1
print(position + 1)


L1 = input()
L2 = input()
p = 1
k = 0
if len(L1) >= 1 and len(L2) <= 50 and (len(L2) >= 1) and (len(L2) <= 50):
	for i in range(len(L2)):
		if L1[k] == L2[i]:
			p += 1
			k += 1
		else:
			continue
	print(p)


stones = input()
commands = input()
moves = 1
tracker = 0
for x in commands:
	current = stones[tracker]
	if x == current:
		moves += 1
		tracker += 1
print(moves)


import sys
my_file = sys.stdin
s = my_file.readline()
t = my_file.readline()
res = 1
for char in t:
	if char == s[0]:
		res += 1
		s = s[1:]
print(res)


s = input()
s2 = input()
ans = 0
for i in s2:
	ans += s[ans] == i
print(ans + 1)


stones = input()
moves = input()
index = 0
for i in moves:
	if i == stones[index]:
		index += 1
print(index + 1)


def watermelon():
	n = int(input())
	if n > 3 and n % 2 == 0:
		print('YES')
	else:
		print('NO')

def way_to_long():
	for _ in range(int(input())):
		s = input()
		if len(s) > 10:
			print(s[0] + str(len(s) - 2) + s[-1])
		else:
			print(s)

def marks():
	(n, m) = map(int, input().split())
	arr = []
	for _ in range(n):
		arr.append(input())
	cnt = 0
	for i in range(n):
		for j in range(m):
			sub = arr[i][j]
			for k in range(n):
				if arr[k][j] > sub:
					break
			else:
				cnt += 1
				break
	print(cnt)

def c_strings():
	s = input()
	t = input()
	i = 0
	j = 0
	cnt = 1
	while i < len(s) and j < len(t):
		if s[i] == t[j]:
			cnt += 1
			i += 1
			j += 1
		else:
			j += 1
	print(cnt)
c_strings()


n = input()
k = input()
an = 0
ak = 0
pos = 1
while an < len(n) and ak < len(k):
	if n[an] == k[ak]:
		pos += 1
		an += 1
		ak += 1
	else:
		ak += 1
print(pos)


ans = 1
j = 0
q = input()
w = input()
for i in range(len(w)):
	if w[i] == q[j]:
		ans += 1
		j += 1
print(ans)


array1 = input()
array2 = input()
i = 0
for j in range(0, len(array2)):
	if array2[j] == array1[i]:
		i += 1
print(i + 1)


p = input()
ins = input()
pos = 0
for i in ins:
	if i == p[pos]:
		pos += 1
print(pos + 1)


def stones(s, t):
	ans = 1
	i = 0
	j = 0
	while i < len(s) and j < len(t):
		if s[i] == t[j]:
			ans += 1
			i += 1
		j += 1
	return ans
s = input()
t = input()
print(stones(s, t))


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
s1 = input()
s2 = input()
ll = len(s2)
j = 0
for i in range(ll):
	if s2[i] == s1[j]:
		j += 1
print(j + 1)


def solve(test):
	ans = 0
	s = input()
	t = input()
	for i in range(len(t)):
		if ans < len(s) and s[ans] == t[i]:
			ans += 1
	print(ans + 1)
t = 1
for _ in range(t):
	solve(_ + 1)


s = input()
t = input()
cnt = 1
for i in t:
	if s[cnt - 1] == i:
		cnt += 1
print(cnt)


a = input()
t = input()
l = 1
for i in range(len(t)):
	if t[i] == a[l - 1]:
		l += 1
print(l)


s = input()
t = input()
position_s = 0
for j in range(len(t)):
	if s[position_s] == t[j]:
		position_s += 1
print(position_s + 1)


c = input()
t = input()
index = 0
for i in range(len(t)):
	if t[i] == c[index]:
		index += 1
print(index + 1)


n = input()
s = input()
flag = 0
for i in s:
	if n[flag] == i:
		flag += 1
print(flag + 1)


(x, y) = (input(), input())
(i, j) = (0, 0)
ans = 1
while i < len(x) and j < len(y):
	if x[i] == y[j]:
		ans += 1
		i += 1
	j += 1
print(ans)


stones = input()
instr = input()
_ans = 1
for x in instr:
	if x == stones[_ans - 1]:
		_ans = _ans + 1
print(_ans)


pole = input()
commands = input()
curX = 0
for c in commands:
	if c == pole[curX]:
		curX += 1
print(curX + 1)


x = input()
y = input()
c = 0
n = len(x)
m = len(y)
for i in y:
	if x[c] == i:
		c = c + 1
		if c == n - 1:
			break
print(c + 1)


stones = input()
instructions = input()
count = 0
for i in instructions:
	if stones[count] == i:
		count += 1
print(count + 1)


s = input()
t = input()
i = j = 0
k = len(t)
while j < k:
	if s[i] == t[j]:
		i = i + 1
	j = j + 1
print(i + 1)


s = list(input())
a = list(input())
c = 1
for i in a:
	if i == s[0]:
		c += 1
		s.remove(i)
print(c)


rgb1 = input()
rgb2 = input()
zero = 0
for i in rgb2:
	if rgb1[zero] == i:
		zero += 1
print(zero + 1)


s = input()
x = input()
pos = 1
for i in range(len(x)):
	if x[i] == s[pos - 1]:
		pos += 1
print(pos)


r = input
s = r()
t = r()
(i, j) = (0, 0)
while i < len(s) and j < len(t):
	i += s[i] == t[j]
	j += 1
print(i + 1)


string1 = str(input())
string2 = str(input())
posicaoS1 = 0
posicaoS2 = 0
while posicaoS1 != len(string1) and posicaoS2 != len(string2):
	if string1[posicaoS1] == string2[posicaoS2]:
		posicaoS1 += 1
		posicaoS2 += 1
	else:
		posicaoS2 += 1
print(posicaoS1 + 1)


x1 = list(input())
x2 = list(input())
x1 = x1[:len(x2)]
pos = 1
to_rem = 0
for i in x1:
	for j in x2:
		if j == i:
			pos += 1
			to_rem += 1
			break
		to_rem += 1
	x2 = x2[to_rem:]
	to_rem = 0
	if len(x2) == 0:
		break
print(pos)


s = input()
ins = input()
res = 0
for i in ins:
	if i == s[res]:
		res += 1
print(res + 1)


a = str(input())
b = str(input())
sum = 0
if a == b:
	print(len(b))
	exit(0)
for i in range(0, len(b)):
	if b[i] == a[sum]:
		sum = sum + 1
	else:
		continue
print(sum + 1)


[P, I] = [input(), input()]
p = 0
for i in I:
	if i == P[p]:
		p += 1
print(p + 1)


s = input()
t = input()
index = 0
for c in t:
	if s[index] == c:
		index += 1
print(index + 1)


listOfStones = list(input())
listOfInstructions = list(input())
positionOfLiss = 1
for instruction in listOfInstructions:
	if instruction == listOfStones[positionOfLiss - 1]:
		positionOfLiss += 1
print(positionOfLiss)


x = '0' + input()
t = input()
c = 1
for i in t:
	if x[c] == i:
		c += 1
print(c)


def colorful():
	stones = input()
	instructions = input()
	position = 0
	for i in range(len(instructions)):
		if instructions[i] == stones[position]:
			position += 1
	return position + 1
print(colorful())


n = input()
t = input()
move = 1
next_color = 0
i = 0
while i < len(t):
	if n[next_color] == t[i]:
		move += 1
		next_color += 1
		i += 1
	else:
		i += 1
print(move)


s = input().strip()
t = input().strip()
i_s = 0
for c in t:
	if c == s[i_s]:
		i_s += 1
print(i_s + 1)


x = input()
y = input()
count = 0
l = 0
j = 0
while l < len(y):
	if x[j] == y[l]:
		j += 1
		count += 1
	l += 1
print(count + 1)


t = input()
n_t = len(t)
s = input()
n_s = len(s)
cur_s = 0
cur_t = 0
while cur_s != n_s:
	if s[cur_s] == t[cur_t]:
		cur_t += 1
	cur_s += 1
print(cur_t + 1)


gems = input()
instr = input()
i = 0
for c in instr:
	if c == gems[i]:
		i += 1
print(i + 1)


s = input()
n = input()
c = 0
for i in n:
	if i == s[c]:
		c += 1
print(c + 1)


s = input()
t = input()
location = 0
for i in t:
	if i == s[location]:
		location += 1
print(location + 1)


s = input()
t = input()
n = 0
count = 1
for i in s:
	j = n
	while j != len(t):
		if i == t[j]:
			count += 1
			n = j + 1
			break
		j += 1
	if j == len(t):
		break
print(count)


s = input()
p = input()
j = 0
c = 0
for i in range(len(p)):
	if p[i] == s[j]:
		c += 1
		j += 1
print(c + 1)


s = input()
t = input()
m = 0
if len(s) == 1:
	print('1')
else:
	for i in t:
		if s[m] == i:
			m += 1
	print(m + 1)


def solve(str1, str2):
	currentState = 1
	for i in str2:
		if str1[currentState - 1] == i:
			currentState += 1
	print(currentState)
string = input()
string2 = input()
solve(string, string2)


s = input()
t = input()
i = 1
for j in t:
	if j == s[i - 1]:
		i += 1
print(i)


s = input()
t = input()
x = 0
for i in range(len(t)):
	if t[i] == s[x]:
		x += 1
	else:
		continue
print(x + 1)


(s, t) = (list(input()), list(input()))
ns = len(s)
for i in t:
	if i == s[0]:
		s = s[1:]
print(ns - len(s) + 1)


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	s = input()
	t = input()
	i = 0
	for a in t:
		if s[i] == a:
			i += 1
	print(i + 1)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


s = input()
k = input()
c = 0
ind = 0
for i in range(len(k)):
	if s[ind] == k[i]:
		c += 1
		ind += 1
print(c + 1)


data = input()
instruction = input()
position = 1
for instruct in instruction:
	if data[position - 1] == instruct:
		position += 1
print(position)


S = input()
k = 0
S1 = input()
for i in range(len(S1)):
	if S1[i] == S[k]:
		k = k + 1
	if k + 1 == len(S):
		break
print(k + 1)


s = input()
t = input()
c = 0
l = 0
for i in t:
	l = l + 1
for i in range(l):
	if s[c] == t[i]:
		c = c + 1
print(c + 1)


string = input()
instructions = input()
position = 1
current = string[position - 1]
for instruction in instructions:
	if instruction == current:
		position += 1
		current = string[position - 1]
print(position)


s = ' ' + input()
t = input()
pos = 1
for (i, v) in enumerate(t):
	if s[pos] == v:
		pos += 1
print(pos)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
s = input()
t = input()
ans = 0
for i in t:
	if s[ans] == i:
		ans += 1
print(ans + 1)


line = input()
commands = input()
current = line[0]
j = 0
for i in commands:
	if i == line[j]:
		j += 1
print(j + 1)


stone = input()
inst = input()
stop = 0
for i in range(len(inst)):
	if inst[i] == stone[stop]:
		stop += 1
print(stop + 1)


s = list(input())
t = list(input())
(ans, x) = (0, 0)
for i in range(len(t)):
	if t[i] == s[x]:
		x += 1
print(x + 1)


a = list(input())
b = list(input())
i = 0
for j in b:
	if j == a[i]:
		i += 1
	else:
		pass
print(i + 1)


s = input()
t = input()
a = 1
b = 0
for i in s:
	for j in range(b, len(t)):
		if i == t[j]:
			a = a + 1
			b = b + 1
			break
		else:
			b = b + 1
print(a)


s = input()
t = input()
a = 0
b = 0
for i in range(len(t)):
	if t[i] == s[int(a)]:
		a += 1
	else:
		b += 1
print(a + 1)


def solution(s, t):
	pos = 0
	result = 1
	for i in range(len(t)):
		if t[i] == s[pos]:
			pos += 1
			result += 1
	return result

def main():
	s = list(input())
	t = list(input())
	print(solution(s, t))
main()


s = input().strip()
t = input().strip()
n = len(t)
j = 0
for i in range(n):
	if t[i] == s[j]:
		j += 1
print(j + 1)


def ColourfulStones():
	stones = input().strip()
	cmd = input().strip()
	pos = 0
	for i in range(len(cmd)):
		pos += cmd[i] == stones[pos]
	return pos + 1
a = ColourfulStones()
print(a)


stones = input()
instr = input()
counter = 0
i = 0
for l in instr:
	if l == stones[i]:
		counter += 1
		i += 1
print(counter + 1)


s = input()
t = input()
pos = 0
i = 0
while pos < len(s) and i < len(t):
	if s[pos] == t[i]:
		pos += 1
		i += 1
	else:
		i += 1
print(pos + 1)


a = input()
b = input()
i = 0
j = 0
while j < len(b):
	if b[j] == a[i]:
		i += 1
	j += 1
print(i + 1)


s = list(input())
t = list(input())
count = 1
pos = 0
for i in t:
	if i == s[pos]:
		pos += 1
		count += 1
print(count)


stone = input()
ins = input()
c = 0
pc = 0
for i in ins:
	if i == stone[pc]:
		pc += 1
		c += 1
print(c + 1)


a = str(input())
b = str(input())
x = int(0)
y = int(0)
while x < len(b):
	if b[x] == a[y]:
		y = y + 1
	x = x + 1
print(y + 1)


I = input
(s, t, k) = (I(), I(), 0)
for i in t:
	k += i == s[k]
print(k + 1)


a = input()
b = input()
k = 0
for i in b:
	if i == a[k]:
		k += 1
print(k + 1)


s = str(input())
t = str(input())
s.split()
t.split()
count = 0
for i in range(len(t)):
	if t[i] == s[count]:
		count += 1
	else:
		continue
print(count + 1)


i = input
(a, b) = (i(), i())
r = 0
for x in b:
	r += a[r] == x
print(r + 1)


str = input()
str2 = input()
index = 0
for i in range(len(str2)):
	if str[index] == str2[i]:
		index += 1
print(index + 1)


(l1, l2) = (input(), input())
c = 0
for i in range(len(l2)):
	if l2[i] == l1[c]:
		c += 1
print(c + 1)


s = list(input())
ins = list(input())
current = 0
for i in ins:
	if i == s[current]:
		current += 1
print(current + 1)


x = input()
y = input()
word1 = list()
word2 = list()
for i in x:
	word1.append(i)
c = len(x)
r = len(y)
for j in y:
	word2.append(j)
count = 0
l = 0
j = 0
while l < r:
	if word1[j] == word2[l]:
		j += 1
		count += 1
	l += 1
print(count + 1)


Sequence = input()
Commands = input()
position = 1
for c in Commands:
	if Sequence[position - 1] == c:
		position += 1
print(position)


s = input()
instructions = input()
pos = 1
for i in range(len(instructions)):
	if instructions[i] == s[pos - 1]:
		pos += 1
		if pos == len(s):
			break
print(pos)


s = input()
t = input()
s_l = list(s)
n = 0
c = 0
for i in s_l[:len(s) - 1]:
	for c in range(c, len(t)):
		if t[c] == i:
			n += 1
			break
	c += 1
	if c == len(t):
		break
print(n + 1)


s = input()
t = input()
i = 0
for inst in t:
	if s[i] == inst:
		i += 1
print(i + 1)


s = input('')
t = input('')
position = 1
for c in t:
	if s[position - 1] == c:
		position = position + 1
print(position)


st1 = input()
st2 = input()
i = 0
for c in st2:
	if st1[i] == c:
		i += 1
print(i + 1)


initS = input()
q = input()
ans = 0
for i in range(len(q)):
	if q[i] == initS[ans]:
		ans += 1
print(ans + 1)


def solve(s, t):
	p = 0
	for i in t:
		if i == s[p]:
			p += 1
	return p + 1

def main():
	s = input()
	t = input()
	print(solve(s, t))
main()


s = input()
t = input()
cur = 0
for i in t:
	if i == s[cur]:
		cur += 1
print(cur + 1)


r = input()
s = input()
z = 0
for i in s:
	if i == r[z]:
		z = z + 1
print(z + 1)


s = input()
t = input()
int1 = 0
for i in t:
	if i == s[int1]:
		int1 += 1
print(int1 + 1)


s = input()
t = input()
s_count = 0
steps = 1
for i in t:
	if s[s_count] == i:
		steps += 1
		s_count += 1
print(steps)


string = input()
instruction = input()
currentchar = string[0]
currentpos = 0
for char in instruction:
	if char == currentchar:
		currentpos += 1
		currentchar = string[currentpos]
print(str(currentpos + 1))


def solution():
	positions = input()
	instructions = input()
	current_location = 0
	for instruction in instructions:
		if instruction == positions[current_location]:
			current_location += 1
	print(current_location + 1)
solution()


from sys import stdin
s = stdin.readline().strip()
i = stdin.readline().strip()

def solution(s, us):
	res = []
	pos = 0
	for x in i:
		if x == s[pos]:
			pos += 1
	return pos + 1
print(solution(s, i))


n = input()
k = input()
i = 0
for j in range(len(k)):
	if n[i] == k[j]:
		i += 1
print(i + 1)


str = input()
j = 0
inst = input()
for i in inst:
	j += i == str[j]
print(j + 1)


def solve():
	cs = input()
	ts = input()
	p = 0
	for e in ts:
		if e == cs[p]:
			p += 1
	print(p + 1)
	return None
solve()


s = input()
t = input()
r = 0
for i in t:
	if i == s[r]:
		r = r + 1
print(r + 1)


a = input().strip()
b = input().strip()
k = 1
for i in range(len(b)):
	if b[i] == a[k - 1]:
		k += 1
	else:
		pass
print(k)


(S, T) = (input(), input())
s = t = 0
while t < len(T):
	if S[s] == T[t]:
		s += 1
	t += 1
print(s + 1)


path = input()
instructions = input()
position = 1
for i in range(0, len(instructions)):
	if instructions[i] == path[position - 1]:
		position += 1
print(position)


from itertools import product
from math import ceil

def binary_table(string_with_all_characters, length_to_make):
	return [''.join(x) for x in product(string_with_all_characters, repeat=length_to_make)]

def all_possible_substrings(string):
	return [int(string[i:j]) for i in range(len(string)) for j in range(i + 1, len(string) + 1)]

def number_of_substrings(length):
	return int(length * (length + 1) / 2)

def is_prime(num):
	for i in range(2, num):
		if num / i == int(num / i) and num != i:
			return False
	return True
first = list(input())
second = list(input())
num = 1
for i in second:
	if not first:
		break
	if i == first[0]:
		num += 1
		del first[0]
print(num)


seq = list(input())
ins = list(input())
x = 0
y = 1
for i in range(len(ins)):
	if ins[i] == seq[x]:
		x = x + 1
		y = y + 1
print(y)


s = [n for n in input()]
z = [n for n in input()]
l = 0
for n in z:
	if s[l] == n:
		l += 1
	else:
		l = l
print(l + 1)


s = input()
instr = input()
n = len(s)
curr = 0
m = len(instr)
cnt = 0
for i in range(m):
	if instr[i] == s[curr]:
		cnt += 1
		curr += 1
print(cnt + 1)


str1 = input()
str2 = input()
cnt = 0
j = 0
for i in range(len(str2)):
	if str2[i] == str1[j]:
		j += 1
print(j + 1)


def position_finder(s, t):
	pos = 0
	for char in t:
		if char == s[pos]:
			pos += 1
	return pos + 1
s = input()
t = input()
print(position_finder(s, t))


stones = input()
instructions = input()
counter = 0
for c in instructions:
	if stones[counter] == c:
		counter += 1
print(counter + 1)


road = input()
t = input()
cur = 0
for i in range(len(t)):
	if road[cur] == t[i]:
		cur += 1
print(cur + 1)


S1 = input()
k = 0
S2 = input()
for i in range(len(S2)):
	if S2[i] == S1[k]:
		k += 1
print(k + 1)


stones = str(input())
instructions = str(input())
p = 0
for i in instructions:
	if i == stones[p]:
		p += 1
print(p + 1)


s = input()
ss = input()
(i, j) = (0, 0)
while i < len(s) and j < len(ss):
	if s[i] == ss[j]:
		i += 1
		j += 1
	else:
		j += 1
print(i + 1)


a = list(input())
b = list(input())
c = 1
for i in range(1):
	for j in b:
		if a[i] == j:
			c += 1
			i += 1
print(c)


(a, b) = (input(), input())
(List1, List2, j, count) = (list(a), list(b), 0, 1)
for i in range(len(b)):
	if List2[i] == List1[j]:
		(j, count) = (j + 1, count + 1)
print(count)


s = input()
l = input()
ip = 0
pos = 0
while ip < len(l):
	if s[pos] == l[ip]:
		pos += 1
	ip += 1
print(pos + 1)


t = input()
c = input()
liss_pos = 0
for a in range(len(c)):
	if c[a] == t[liss_pos]:
		liss_pos += 1
print(liss_pos + 1)


a = input()
b = input()
i = 0
while b:
	if b[0] == a[i]:
		i += 1
	b = b[1:]
print(i + 1)


stones = list(map(str, input()))
colors = list(map(str, input()))
move = 1
counter = 0
for i in range(len(colors)):
	if colors[i] == stones[counter]:
		move += 1
		counter += 1
print(move)


os = input()
dt = input()
ans = 1
for i in range(len(dt)):
	if dt[i] == os[ans - 1]:
		ans += 1
print(ans)


a = input()
instructions = input()
l = 1
for x in instructions:
	if a[l - 1] == x:
		l += 1
print(l)


s = [str(x) for x in input()]
t = [str(x) for x in input()]
ans = 1
i = 0
j = 0
while i < len(s) and j < len(t):
	if s[i] == t[j]:
		ans += 1
		i += 1
		j += 1
	else:
		j += 1
print(ans)


pos = 1
st1 = list(input())
st2 = list(input())
j = 0
for i in range(len(st2)):
	if st2[i] == st1[j]:
		pos += 1
		j += 1
print(pos)


s = input()
t = input()
tmp = list(s)
t = list(t)
pos = 0
j = 0
for i in range(len(t)):
	if s[j] == t[i]:
		j += 1
		pos += 1
print(pos + 1)


s = input()
s2 = input()
ans = 0
for i in range(len(s2)):
	if s[ans] == s2[i]:
		ans += 1
		if ans == len(s):
			break
print(ans + 1)


a = list((i for i in input()))
b = list((y for y in input()))
x = 1
y = 0
for i in range(len(a)):
	if y <= len(b) - 1:
		while a[i] != b[y]:
			y += 1
			if y > len(b) - 1:
				break
		if y <= len(b) - 1 and i < len(a) - 1:
			if a[i] == b[y]:
				y += 1
				x += 1
print(x)


stones = input()
instr = input()
j = 0
for i in range(len(instr)):
	if instr[i] == stones[j]:
		j += 1
print(j + 1)


from sys import stdin, stdout

def sin():
	return stdin.readline().rstrip()

def listInput():
	return list(map(int, sin().split()))

def printBS(li):
	if not li:
		return
	for i in range(len(li) - 1):
		stdout.write('%d ' % li[i])
	stdout.write('%d\n' % li[-1])
s = sin()
s1 = sin()
pos = 0
for i in range(len(s1)):
	if s[pos] == s1[i]:
		pos += 1
print(pos + 1)


s = input()
t = input()
curr_pos = 0
for i in t:
	if i == s[curr_pos]:
		curr_pos += 1
print(curr_pos + 1)


(s, t) = (str(input()), str(input()))
stone = 0
for i in range(len(t)):
	if t[i] == s[stone]:
		stone += 1
	else:
		continue
print(stone + 1)


s = list(input())
t = list(input())
j = 0
for i in range(len(t)):
	if t[i] == s[j]:
		j += 1
		continue
	elif t[i] != s[j]:
		continue
print(j + 1)


a = input()
b = input()
count = 1
x = 0
for i in b:
	if i == a[x]:
		count += 1
		x += 1
	if count == len(a):
		break
print(count)


n = input()
m = input()
d = 0
posn = 1
for j in m:
	if j == n[d]:
		d += 1
		posn += 1
print(posn)


s = list(input())
instruction = str(input())
count = 0
j = 0
current_pos = s[j]
for i in instruction:
	if i == current_pos:
		j = j + 1
		current_pos = s[j]
		count = count + 1
print(count + 1)


stones = input()
commands = input()
stone_num = 1
for i in commands:
	if i == stones[stone_num - 1]:
		stone_num += 1
print(stone_num)


n = input()
t = input()
j = 0
l = len(t)
for i in range(l):
	if t[i] == n[j]:
		j += 1
print(j + 1)


cstones = list(input())
inst = list(input())
count = 0
for i in range(len(inst)):
	if cstones[count] == inst[i]:
		count += 1
print(count + 1)


st1 = input()
st2 = input()
step = 0
s = 0
for i in st2:
	if i == st1[s]:
		s += 1
		step += 1
print(step + 1)


s = input()
ins = input()
i = 0
for char in ins:
	if char == s[i]:
		i += 1
print(i + 1)


i = 0
s = input()
l = len(s)
a = input()
j = 0
for i in a:
	if j >= l:
		break
	if i == s[j]:
		j += 1
print(j + 1)


s = input()
t = input()

def fn(s, t):
	pos = 0
	for i in t:
		if i == s[pos]:
			pos += 1
	return pos + 1
print(fn(s, t))