def reppref(s, n)
	(s.codepoints * ((s.size + n - 1) / s.size))
end

s = gets.chomp
t = gets.chomp

ptn = reppref(t, s.size + t.size)
mp = [-1]
j = -1
ptn.size.times{|i|
	j = mp[j] while j >= 0 && ptn[i] != ptn[j]
	j += 1
	mp.push(j)
}

j = 0
mx = 0
reppref(s, s.size * 2 + t.size).each{|x|
	j = mp[j] while j == ptn.size || (j >= 0 && ptn[j] != x)
	j += 1
	mx = j if mx < j
}
puts (mx >= s.size + t.size ? -1 : mx / t.size)
