def partial_match_table(word): table = [0] * (len(word) + 1) table[0] = -1 i, j = 0, 1 while j < len(word): matched = word[i] == word[j] if not matched and i > 0: i = table[i] else: if matched: i += 1 j += 1 table[j] = i return table def kmp_search(text, word): table = partial_match_table(word) i, p = 0, 0 results = [] while i < len(text) and p < len(word): if text[i] == word[p]: i += 1 p += 1 if p == len(word): p = table[p] results.append((i-len(word), i)) elif p == 0: i += 1 else: p = table[p] return results s = input().strip() t = input().strip() if len(t) == 1 and t in s: import sys print(-1) sys.exit() rs = [] for i, (a, b) in enumerate(kmp_search(s, t)): # print(a,b-1) rs.append((a, 1, i)) rs.append((b-1, 0, i)) rs.sort() r = 0 ts = set() for x, f, i in rs: if f == 1: ts.add(i) continue if f == 0 and i in ts: ts = set() r += 1 continue print(r)