def check(t,s):
    i=0
    for j in range(len(s)):
        if(i==len(t)):
            return (True,j)
        if(t[i]==s[j]):
            i+=1
    if(i==len(t)):
        return (True,len(s))
    return False,-1
        

def solve(s,t):
    new_s = s
    for a in t:
        if a not in s:
            return -1
    l = 1
    r = 1005
    final = 10**100
    while(l<=r):
        mid = (l+r)//2
        new_s = s*mid
        done,ans = check(t,new_s)
        if(done):
            final = min(final,ans)
            r = mid-1
        else:
            l = mid+1
    return final

s = input()
t = input()
print(solve(s,t))