#include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct rollingHash {
    ll mo[2] = {1000000007, 1000000009};
    ll base[2] = {1009, 1007};
    vector<ll> hash[2], power[2];
    rollingHash() {}
    rollingHash(string s) {
        hash[0].resize(s.size()+1); hash[1].resize(s.size()+1);
        power[0].resize(s.size()+1); power[1].resize(s.size()+1);
        init(s);
    }
    inline ll mul(ll a, ll b, ll md) const {
        return a * b % md;
        // unsigned long long y = a*b;
        // unsigned xh = (unsigned)(y>>32), xl = (unsigned)y, d, m;
        // asm(
        //     "divl %4; \n\t"
        //     : "=a" (d), "=d" (m)
        //     : "d" (xh), "a" (xl), "r" (md)
        // );
        // return a;
    }
    // O(|S|)
    void init(string s) {
        REP(i, 2) {
            power[i][0] = 1;
            FOR(j, 1, s.size()+1) power[i][j] = mul(power[i][j-1], base[i], mo[i]);
        }
        // 1-indexの累積和
        REP(i, 2) REP(j, s.size()) {
            hash[i][j+1] = (hash[i][j]+mul(power[i][j], s[j], mo[i]))%mo[i];
        }
    }
    // [l1,r1) と [l2,r2) が一致するか
    bool equal(int l1, int r1, int l2, int r2) {
        REP(i, 2) {
            ll a = (hash[i][r1]-hash[i][l1]+mo[i])%mo[i];
            ll b = (hash[i][r2]-hash[i][l2]+mo[i])%mo[i];
            if(mul(a,power[i][l2-l1],mo[i]) != b) return false;
        }
        return true;
    }
    // [l,r)
    PII get(int l, int r) {
        PII ret;
        ret.first = (hash[0][r]-hash[0][l]+mo[0])%mo[0];
        ret.first = mul(ret.first, power[0][hash[0].size()-1-l], mo[0]);
        ret.second = (hash[1][r]-hash[1][l]+mo[1])%mo[1];
        ret.second = mul(ret.second, power[1][hash[1].size()-1-l], mo[1]);
        return ret;
    }
};

// 「SとS[i:|S|-1]の最長共通接頭辞の長さ」を記録した配列AをO(|S|)で構築する
// aaabaaaab
// 921034210
vector<ll> Zalgo(string s) {
    const ll n = s.size();
    vector<ll> v(n);
    v[0] = n;
    int i = 1, j = 0;
    while (i < n) {
        while (i+j < n && s[j] == s[i+j]) ++j;
        v[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < n && k+v[k] < j) v[i+k] = v[k], ++k;
        i += k; j -= k;
    }
	return v;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;
    const ll n = s.size(), m = t.size();

    FOR(i, n, n+m-1) s += s[i%n];
    s = t + s;

    vector<ll> v = Zalgo(s);

    vector<vector<ll>> g(n);
    REP(i, n) {
        // s[i],s[i+1],…,s[i+m-2],s[i+m-1] == t の判定
        if(v[i+m] >= m) {
            g[i].push_back((i+m)%n);
        }
    }

    ll idx = 1;
    bool loop = false;
    vector<ll> used(n);
    function<void(ll)> isloop = [&](ll v) {
        // cout << v << endl;
        if(used[v]) {
            if(used[v] == idx) loop = true;
            return;
        }
        used[v] = idx;
        for(auto to: g[v]) {
            isloop(to);
        }
    };
    REP(i, n) {
        if(!used[i]) {
            // cout << "start:" << i << endl;
            isloop(i);
            idx++;
            // cout << used << endl;
        }
    }
    if(loop) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> dist(n, -1);
    function<void(ll)> dfs = [&](ll v) {
        if(dist[v] != -1) return;
        dist[v] = 0;
        for(auto to: g[v]) {
            dfs(to);
            chmax(dist[v], dist[to] + 1);
        }
    };
    REP(i, n) {
        if(dist[i] == -1) {
            dfs(i);
        }
    }

    ll ma = 0;
    REP(i, n) chmax(ma, dist[i]);
    cout << ma << endl;

    return 0;
}


Measured memory_bytes: 70320