s = gets.chomp
t = gets.chomp
sx = s * [(s.length.lcm(t.length) / s.length), 2].max

i = 0
while true
    if sx.match(t * i)
        i += 1
    else
        break
    end
end
if sx.length == t.length * (i-1)
    puts -1
else
    puts i - 1
end
