S, T = input(), input() S = S.replace(T, T[0] + '.' + T[1:]).replace("a.a.aa","aa.aa") print(-1 if T in S else S.count('.'))