s = list(input())
t = list(input())

ls = len(s)
lt = len(t)
st = set(t)
flg = 0

for i in st:
  if s.count(i)==0:
    flg = -1
    print(flg)
    exit()

i = 0
j = 0
s = s*100000

while i<lt:
  if t[i]==s[j]:
    i+=1
  j+=1
  
print(j)