local s = io.read()
local t = io.read()
if #s < #t then
  s, t = t, s
end
local slen = #s
local tlen = #t
s = s .. s

local mma = math.max
local findpos = s:find(t, 1)
local maxlength = 0
while findpos do
  if slen < findpos then
    break
  end
  local curlength = 1
  while true do
    local p = findpos + tlen * curlength
    if p < findpos + slen and t == s:sub(p, p + tlen - 1) then
      curlength = curlength + 1
    else
      break
    end
  end
  maxlength = mma(maxlength, curlength)
  if slen <= curlength * tlen then
    maxlength = -1
    break
  end
  findpos = s:find(t, findpos + tlen)
end
print(maxlength)
