S=input() T=input() U=T[:-1]+"."+T[-1:] s=S.replace(T,U).replace(T,U) n=s.count('.') if len(T)==1 and n>0: print(-1) else: print(n)