s = gets.chomp
t = gets.chomp

max = 0
start = 0
while start < s.length
    i = start
    j = 0
    if s[i] == t[j] then
        i += 1
        j += 1
        while s[i % s.length] == t[j % t.length]
            if i % s.length == start && j % t.length == 0 then
                puts -1
                return
            end
            i += 1
            j += 1
        end
        if max < j / t.length then
            max = j / t.length
        end
    end
    start += 1
end

puts max
