# frozen_string_literal: true

def z_algorithm(s)
  n = s.size
  return [] if n == 0

  z = [0]*n
  j = 0
  1.upto(n-1){ |i|
    z[i] = j+z[j] <= i ? 0 : j+z[j]-i < z[i-j] ? j+z[j]-i : z[i-j]
    z[i] += 1 while i+z[i]<n && s[z[i]]==s[i+z[i]]
    j = i if j+z[j] < i+z[i]
  }
  z[0] = n
  return z
end

s, t = $<.map &:chomp

ss = s+s
ss += s while ss.size < t.size*2
z = z_algorithm(t+ss)[t.size,s.size].map{ |z| z >= t.size }

memo = [nil]*s.size

def dfs(u, tl, z, memo)
  if memo[u] then
    memo[u] = 10**9 if memo[u] < 0
    return memo[u]
  end
  if z[u]
    memo[u] = -1
    return memo[u] = dfs((u+tl) % z.size, tl, z, memo)+1
  else
    return memo[u] = 0
  end
end

ans = (0 ... s.size).map{ |u| dfs(u, t.size, z, memo) }.max
ans = -1 if ans >= 10**9

puts ans
