import std.stdio;
import std.conv;
import std.string;
import std.array;

void main()
{
    string s = readln.chomp;
    string t = readln.chomp;

    string tmp = s;
    while (tmp.length < t.length * 2) tmp ~= s;
    tmp = tmp.replace(t, "?");
    tmp = (tmp ~ tmp).replace(t, "?");

    int max_cnt = 0;
    int cnt = 0;
    foreach (char c; tmp){
        if (c == '?'){
            cnt++;
        } else {
            if (cnt > max_cnt) max_cnt = cnt;
            cnt = 0;
        }
    }
    if (cnt > max_cnt) max_cnt = cnt;

    if (max_cnt < tmp.length){
        writeln(max_cnt);
    } else {
        writeln(-1);
    }
}

