# https://tjkendev.github.io/procon-library/python/string/z-algorithm.html def z_algo(S): N = len(S) A = [0]*N i = 1; j = 0 A[0] = l = len(S) while i < l: while i+j < l and S[j] == S[i+j]: j += 1 if not j: i += 1 continue A[i] = j k = 1 while l-i > k < j - A[k]: A[i+k] = A[k] k += 1 i += k; j -= k return A S = input() T = input() z = z_algo(T+S) cnt = 0 i = len(T) while i=len(T): cnt += 1 i+=len(T)-1 else: i+=1 if len(T)==1: if cnt>0: print(-1) else: print(0) else: print(cnt)