S=input() t=input() ans=10**18 if len(t)==1 and S.count(t)>0: print(-1) exit() for i in range(1,len(t)): u=t[:i]+'.'+t[i:] s=S for i in range(len(t)): s=s.replace(t,u) cnt=s.count('.') ans=min(ans,cnt) print(ans)