s = input() t = input() if len(s) == 1: if s in t: print(-1) else: print(0) exit() ans = 0 pos = 0 n = len(t) for st in s: if st == t[pos]: pos += 1 if pos == n: ans += 1 if t[0] == t[-1]: pos = 1 else: pos = 0 else: pos = 0 print(ans)