S=input() s=input() SL=list(S) SL.sort() sl=list(s) sl.sort() F=0 if len(s)==2: if SL[0]==SL[-1] and sl[0]==sl[1] and sl[0]==SL[0]: F=1 ANS=S.replace(s,"A") ans=ANS.count("A") if F==1: print(ans*2-1) exit() if ans>=1: if len(s)==1: print(-1) exit() else: print(ans) else: print(ans)