S, T = readlines.map(&:chomp)

rep = ->(s, n){s.codepoints * ((s.size + n - 1) / s.size)}
ptn = rep[T, S.size + T.size]
mp = [-1]
j = -1
ptn.size.times do |i|
  j = mp[j] while j >= 0 && ptn[i] != ptn[j]
  j += 1
  mp << j
end
j = 0
mx = 0
rep[S, S.size * 2 + T.size].each do |x|
  j = mp[j] while j == ptn.size || (j >= 0 && ptn[j] != x)
  j += 1
  mx = j if mx < j
end
puts mx >= S.size + T.size ? -1 : mx / T.size