def prefix_function(s):
p = [0 for i in range(len(s))]
for i in range(1, len(s)):
l = p[i - 1]
while l > 0 and s[i] != s[l]:
l = p[l - 1]
p[i] = l + (s[i] == s[l])
return p
p = input()
r = input()
p = p[::-1]
r = r[::-1]
pf = prefix_function(p + '$' + r)
ans = 0
pos = len(r) - 1
while pos >= 0:
pos -= pf[len(p) + 1 + pos]
ans += 1
print(ans)