#include <bits/stdc++.h>
using namespace std;

int64_t bpow[2][1000001];
int64_t binv[2];
    
template <size_t N>
class rolling_hash{
    vector<int64_t> mod;
    vector<int64_t> base;
    vector<int64_t> hash;
    size_t len;
 
    int64_t mpow(int64_t x, int64_t y, int64_t m){
        if(y == 0) return 1;
        if(y == 1) return x % m;
        if(y%2 == 0) return mpow(x*x%m, y/2, m);
        return mpow(x*x%m, y/2, m)%m * x % m;
    }
public:
    rolling_hash(vector<int64_t> bases, vector<int64_t> mods)
    : base(bases), mod(mods){
        hash.resize(N);
        for(int i=0;i<N;++i){
            hash[i] = 0;
        }
        len = 0;
        bpow[0][0] = bpow[1][0] = 1;
        for(int i=1;i<=1000000;++i){
            bpow[0][i] = bpow[0][i-1] * base[0] % mod[0];
            bpow[1][i] = bpow[1][i-1] * base[1] % mod[1];
        }
        binv[0] = mpow(base[0], mod[0]-2, mod[0]);
        binv[1] = mpow(base[1], mod[1]-2, mod[1]);
    }
    vector<int64_t> operator()(){
        return hash;
    }
    int64_t operator[](size_t n){
        return hash[n];
    }
    void push_back(char c){
        ++len;
        for(int i=0;i<N;++i){
            hash[i] = (hash[i]*base[i]%mod[i] + c) % mod[i];
        }
    }
    void push_front(char c){
        ++len;
        for(int i=0;i<N;++i){
            hash[i] = (hash[i] + c*bpow[i][len-1]%mod[i]) % mod[i];
        }
    }
    void pop_front(char c){
        --len;
        for(int i=0;i<N;++i){
            hash[i] = (hash[i] - c*bpow[i][len]) % mod[i];
            if(hash[i] < 0) hash[i] += mod[i];
        }
    }
    void pop_back(char c){
        --len;
        for(int i=0;i<N;++i){
            hash[i] = (hash[i] + mod[i] - c) % mod[i];
            hash[i] = hash[i] * binv[i] % mod[i];
        }
    }
};

int main(){
    int p;
    string s, t;
    cin >> s >> t;

    vector<int64_t> mods = {1'000'000'007, 1'000'000'009};
    vector<int64_t> bases = {rand() % mods[0], rand() % mods[1]};
    rolling_hash<2> s_rh(bases, mods), t_rh(bases, mods);

    for(int i=0;i<t.size();++i) t_rh.push_back(t[i]);
    for(int i=0;i<t.size();++i) s_rh.push_back(s[i%s.size()]);
    bool match[500000];
    for(int i=0;i<s.size();++i){
        match[i] = s_rh()==t_rh();
        s_rh.push_back(s[(i+t.size())%s.size()]);
        s_rh.pop_front(s[i]);
    }

    static int dp[500000];
    int ans = 0;
    for(int i=0;i<s.size();++i) dp[i] = -1;
    for(int i=0;i<s.size();++i){
        if(dp[i] >= 0) continue;
        stack<int> st;
        int pos = i;
        while(match[pos]){
            st.push(pos);
            pos = (pos+t.size()) % s.size();
            if(pos == i){
                cout << -1 << endl;
                return 0;
            }
            if(dp[pos] >= 0){
                while(!st.empty()){
                    int f = st.top();
                    st.pop();
                    dp[f] = 1 + dp[pos];
                    ans = max(ans, dp[f]);
                    pos = f;
                }
                goto l_nx;
            }
        }
        dp[pos] = 0;
        while(!st.empty()){
            int f = st.top();
            st.pop();
            dp[f] = dp[pos] + 1;
            ans = max(ans, dp[f]);
            pos = f;
        }
        l_nx:;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 21384