# frozen_string_literal: true

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

  z = [0]*n
  z[0] = n
  i, j = 1, 0
  while i < n
    j += 1 while i+j<n && s[j]==s[i+j]
    z[i] = j
    if j == 0 then
      i += 1
      next
    end
    k = 1
    while i+k<n && k+z[k]<j
      z[i+k] = z[k]
      k += 1
    end
    i += k
    j -= k
  end
  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
