S = input() T = input() if len(T)==1: if S.count(T)==0: print(0) else: print(-1) exit() i = 0 j = 0 cnt = 0 while i