# 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|
    k = j+z[j] <= i ? 0 : j+z[j]-i < z[i-j] ? j+z[j]-i : z[i-j]
    k += 1 while i+k<n && s[k]==s[i+k]
    j = i if j+z[j] < i+k
    z[i] = k
  }
  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 }

vis = [false]*s.size

ans = (0 ... s.size).map{ |u|
  next if vis[u]
  vis[u] = true
  now = u
  cnt = 0
  while z[now]
    now = (now+t.size) % s.size
    vis[now] = true
    cnt += 1
    break if now == u
  end
  now==u && cnt.nonzero? ? 10**9 : cnt
}.compact.max

ans = -1 if ans >= 10**9
puts ans
