#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;
typedef long long ll;

void make_z(const string& str, vector<ll>& z); 

void search(
    const string& text,
    const string& pattern,
    set<ll>& out
){
    string concat = pattern + "$" + text; 
    ll l = concat.size(); 
  
    vector<ll> z(l);
    make_z(concat, z);
 
    out.clear();
    for (ll i = pattern.size() + 1; i < l; ++i){
        if (z.at(i) == pattern.size()){
            out.insert(i - pattern.size() - 1);
        }
    } 
} 

void make_z(const string& s, vector<ll>& z) { 
    const ll n = s.size(); 
    // [L,R] make a window which matches with prefix of s 
    ll L = 0, R = 0; 
 
    for (int i = 1; i < n; ++i) {
        // if i > R nothing matches so we will calculate. 
        // Z[i] using naive way. 
        if (i > R) { 
            L = R = i; 
  
            // R-L = 0 in starting, so it will start 
            // checking from 0'th index. For example, 
            // for "ababab" and i = 1, the value of R 
            // remains 0 and Z[i] becomes 0. For string 
            // "aaaaaa" and i = 1, Z[i] and R become 5 
            while (R < n && s[R-L] == s[R]){
                R++;
            }
            z[i] = R-L; 
            R--; 
        }else{  // i <= R
            // k = i-L so k corresponds to number which 
            // matches in [L,R] interval. 
            const ll k = i-L; 
  
            // if z[k] is less than remaining interval 
            // then z[i] will be equal to z[k]. 
            // For example, str = "ababab", i = 3, R = 5 
            // and L = 2 
            if (z[k] < R-i+1){
                z[i] = z[k]; 
            }else{
                // For example str = "aaaaaa" and i = 2, R is 5, 
                // L is 0 
                // else start from R and check manually 
                L = i; 
                while (R<n && s[R-L] == s[R]){
                    R++;
                }
                z[i] = R-L; 
                R--; 
            }
        } 
    } 
} 

struct union_find {
    vector<ll> par;
    vector<ll> rank;
    vector<ll> count;

    union_find(ll n) : par(n, 0), rank(n, 0), count(n, 1) {
        for(ll i = 0; i < n; ++i){ par.at(i) = i; }
    }

    ll find(ll x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = find(par.at(x));
        }
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y){ return; }
        if(rank.at(x) < rank.at(y)){
            par.at(x) = y;
        }else{
            par.at(y) = x;
            if(rank.at(x) == rank.at(y)){
                rank.at(x)++;
            }
        }

        ll new_count = count.at(x) + count.at(y);
        count.at(find(x)) = new_count;
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    ll size(ll x){
        return count.at(find(x));
    }
};

int main(){
    string s, t;
    getline(cin, s);
    getline(cin, t);

    string s2 = s;
    s2 += s;
    while(s.size() + t.size() > s2.size()){
        s2 += s;
    }

    set<ll> pos;
    search(s2, t, pos);

    union_find uf(s.size());
    ll ans = 0;
    for(ll i = 0; i < s.size(); ++i){
        if(pos.count(i) == 0){ continue; }
        ans = max(ans, 1LL);

        ll next = (i + t.size()) % s.size();
        if(pos.count(next)){
            if(uf.same(i, next)){  // loop
                cout << -1 << endl;
                return 0;
            }else{
                uf.unite(i, next);
            }
            ans = max(ans, uf.size(i));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67124