S = input() T = input() count = 0 while True: if T in S: if len(T) == 1: print(-1) exit() replaceChar = T[:-1] + "." + T[-1] S = S.replace(T, replaceChar, 1) count += 1 print(S) else: break print(count)