#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

struct ROLLING_HASH {
    #define BASE1 1009L
    #define BASE2 1007L
    #define MOD1 1000000007L
    #define MOD2 1000000009L
    vector<ll> vec;
    vector<pl> acc;
    vector<pl> po;

    ll mod_pow (ll x, ll y, ll m) {
        ll ret = 1;
        while (y) {
            if (y&1) ret = ret * x % m;
            x = x * x % m;
            y /= 2;
        }
        return ret;
    }

    void init(vector<ll> _vec) {
        vec = _vec;
        /*
        rep(i,vec.size()) cerr << vec[i] << " ";
        cerr << endl;
        */
        acc.resize(vec.size());
        po.resize(vec.size());
        pl val = pl(0,0);
        rep(i,vec.size()) {
            if (i == 0) {
                po[0] = pl(1,1);
            } else {
                po[i].first = po[i-1].first*BASE1%MOD1;
                po[i].second = po[i-1].second*BASE2%MOD2;
            }
            val.first = (val.first+vec[i]*po[i].first)%MOD1;
            val.second = (val.second+vec[i]*po[i].second)%MOD2;
            acc[i] = val;
        }
    }

    pl get_hash (int l, int r) {
        pl ret;
        ret.first = (acc[r].first-(l==0?0:acc[l-1].first)+MOD1)%MOD1;
        ret.second = (acc[r].second-(l==0?0:acc[l-1].second)+MOD2)%MOD2;
        ret.first = ret.first * mod_pow(po[l].first, MOD1-2, MOD1) % MOD1;
        ret.second = ret.second * mod_pow(po[l].second, MOD2-2, MOD2) % MOD2;
        return ret;
    }
} rs, rt;

string s, t;
vector<ll> vs, vt;
bool ok[2000000];
bool saw[2000000];

int main() {
    cin >> s >> t;
    rep(i,t.size()) {
        vt.push_back(t[i]-'a');
    }
    while (vs.size() < s.size() + t.size()) {
        rep(i,s.size()) {
            vs.push_back(s[i]-'a');
        }
    }
    rs.init(vs);
    rt.init(vt);
    pl pat = rt.get_hash(0, vt.size()-1);
    //cerr << pat.first << " " << pat.second << endl;
    rep(i,s.size()) {
        //cerr << "hash: ";
        //cerr << rs.get_hash(i, i+vt.size()-1).first << " " << rs.get_hash(i, i+vt.size()-1).second << endl;
        if (rs.get_hash(i, i+vt.size()-1) == pat) {
            ok[i] = true;
        }
    }
    /*
    rep(i,s.size()) {
        cerr << ok[i];
    }
    cerr << endl;
    */
    ll ans = 0;
    rep(i,s.size()) {
        if (saw[i]) continue;
        if (!ok[i]) continue;
        ll cnt = 1;
        saw[i] = true;
        int pos = i;
        while (true) {
            pos = (pos + t.size()) % s.size();
            if (pos == i) {
                break;
            }
            saw[pos] = true;
            if (!ok[pos]) break;
            cnt++;
        }
        if (pos == i) {
            ans = -1;
            break;
        }
        pos = i;
        while (true) {
            pos = (pos + s.size()*t.size() - t.size()) % s.size();
            if (pos == i) {
                break;
            }
            saw[pos] = true;
            if (!ok[pos]) break;
            cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 101288