#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

class RollingHash{
    int N;
    unsigned long long base;
    const unsigned long long MOD0 = 1000000007;
    const unsigned long long MOD1 = 1000000009;
    vector<unsigned long long> pow0, pow1;
    vector<unsigned long long> hash_cum0, hash_cum1;
public:
    RollingHash(unsigned long long base=10007) : base(base) {};
    void set(vector<unsigned long long> v){
        N = v.size();

        pow0.resize(N+1);
        pow1.resize(N+1);
        hash_cum0.resize(N+1);
        hash_cum1.resize(N+1);

        pow0[0] = pow1[0] = 1;
        hash_cum0[0] = hash_cum0[0] = 0;

        for(int i=1; i<=N; i++){
            pow0[i] = (pow0[i-1] * base) % MOD0;
            pow1[i] = (pow1[i-1] * base) % MOD1;
        }

        for(int i=1; i<=N; i++){
            hash_cum0[i] = ((base * hash_cum0[i-1]) % MOD0 + v[i-1]) % MOD0;
            hash_cum1[i] = ((base * hash_cum1[i-1]) % MOD1 + v[i-1]) % MOD1;
        }
    }
    // [l, r) のハッシュ値を取得
    pair<unsigned long long, unsigned long long> get(int l, int r){
        unsigned long long hash0 = (hash_cum0[r] + MOD0 - (hash_cum0[l] * pow0[r-l]) % MOD0) % MOD0;
        unsigned long long hash1 = (hash_cum1[r] + MOD1 - (hash_cum1[l] * pow1[r-l]) % MOD1) % MOD1;
        return make_pair(hash0, hash1);
    }
    // 引数で与えられる v のハッシュ値を取得
    pair<unsigned long long, unsigned long long> get(const vector<unsigned long long> &v){
        unsigned long long hash0 = 0;
        unsigned long long hash1 = 0;
        for(int i=0; i<v.size(); i++){
            hash0 = ((base * hash0) % MOD0 + v[i]) % MOD0;
            hash1 = ((base * hash1) % MOD1 + v[i]) % MOD1;
        }
        return make_pair(hash0, hash1);
    }
    // set されている列 v に対して、v[i,:], v[j,:] の LCP 長さを取得する
    int lcp(int i, int j){
        int l = 0;
        int r = min(N-i, N-j)+1;
        while(r - l > 1){
            int m = (l + r) / 2;
            if(get(i, i + m) == get(j, j + m)) l = m;
            else                               r = m;
        }
        return l;
    }
};

int find_root(vector<int> &G, int cur, vector<bool> &vis){
    int par = cur;
    int N = G.size();
    bool fl = false;
    for(int i=0;; i++){
        if(fl && cur == par) return -1;
        fl = true;
        if(vis[cur]) return -2;
        vis[cur] = true;
        if(G[cur]==-1) return cur;
        cur = G[cur];
    }
    return cur;
}

int main(){
    string s0, s, t;
    cin >> s0 >> t;
    s = s0;
    while(s.size() < t.size()) s += s0;
    int Ns = s.size();
    int Nt = t.size();
    vector<unsigned long long> vs(Ns*2), vt(Nt);
    for(int i=0; i<Ns; i++) vs[i] = vs[i+Ns] = s[i] - 'a';
    for(int i=0; i<Nt; i++) vt[i] = t[i] - 'a';

    RollingHash rhs, rht;
    rhs.set(vs);
    rht.set(vt);
    auto hash_t = rht.get(0, Nt);
    vector<int> G(Ns, -1), Ginv(Ns, -1);
    REP(l, Ns){
        int r = l + Nt;
        auto hash_s = rhs.get(l, r);
        if(hash_s == hash_t){
            G[l] = r%Ns;
            Ginv[r%Ns] = l;
        }
    }

    vector<bool> vis(Ns);

    int ans = 0;
    for(int f=0; f<Ns; f++){
        int cur = find_root(Ginv, f, vis);
        if(cur == -1){
            ans = -1;
            break;
        }
        if(cur == -2) continue;
        int cnt = 0;
        for(;G[cur]!=-1;cnt++){
            cur = G[cur];
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 107776