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

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

    // 一文字による無限長回避
    char src_c = s[0];
    int cnt_s = 0;
    foreach (char c; s){
        if (c == src_c) cnt_s++;
    }
    int cnt_t = 0;
    foreach (char c; t){
        if (c == src_c) cnt_t++;
    }
    if (cnt_s == s.length && cnt_t == t.length){
        writeln(-1);
        return;
    }

    uint first_i;
    for (first_i = 0; first_i < s.length; first_i++){
        if (s[first_i] == t[0]) break;
    }
    s = s[first_i..s.length] ~ s[0..first_i];

    s = s.replace(t, "?");

    // s == t * n の場合
    int check = 0;
    foreach (char c; s){
        if (c != '?'){
            check = 1;
            break;
        }
    }
    if (check == 0){
        writeln(-1);
        return;
    }

    int cnt = 0;
    for (uint i = 0; i < s.length && s[i] == '?'; i++){
        cnt++;
    }
    s = s[cnt..s.length] ~ s[0..cnt];

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

    writeln(max_cnt);
}

