S = gets.chomp
T = gets.chomp
ssize = S.size
tsize = T.size

answer = 0
a = 0
b = 0
if ssize >= tsize
    for i in 0...ssize do
        if T[b] == S[i]
            b += 1
            if tsize == b
                a += 1
                b = 0
            end
        else
            if answer < a
                answer = a
            end
            a = 0
            b = 0
        end
    end
    for i in 0...ssize do
        if T[b] == S[i]
            b += 1
            if tsize == b
                a += 1
                b = 0
            end
        else
            if answer < a
                answer = a
            end
            a = 0
            b = 0
        end
    end
    for i in 0...ssize do
        if T[b] == S[i]
            b += 1
            if tsize == b
                a += 1
                b = 0
            end
        else
            if answer < a
                answer = a
            end
            a = 0
            b = 0
        end
    end
    if a > 0 && answer == 0
        puts -1
        exit
    end
else
    n = (tsize / ssize + 1) * 3
    while n > 0
        for i in 0...ssize do
            if T[b] == S[i]
                b += 1
                if tsize == b
                    a += 1
                    b = 0
                end
            else
                if answer < a
                    answer = a
                end
                a = 0
                b = 0
            end
        end
        n -= 1
    end
    if a > 0 && answer == 0
        puts -1
        exit
    end
end

puts answer