s=input() t=input() if len(t)==1 and t in s: print("-1") elif len(set(t))==1: print(s.count(*set(t))) else: print(s.count(t))