#include <bits/stdc++.h>

using namespace std;

#define min3(a, b, c)           min((a), min((b), (c)))
#define max3(a, b, c)           max((a), max((b), (c)))
#define lcm(a,b)                (a / __gcd(a,b) ) *b
#define gcd(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define sqr(a)                  ((a)*(a))
#define FOR(a, b)               for(int i=a; i<b; i++)
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define pb                      push_back
#define mk                      make_pair
#define ff                      first
#define ss                      second
#define lb                      lower_bound
#define ub                      upper_bound
#define all(a)                  a.begin(),a.end()
#define FASTIO                  ios_base::sync_with_stdio(0);cin.tie(NULL);

void getZarr(string str, int Z[]);

int cnt=0;
vector<int> search(string text, string pattern)
{
    vector <int> found;
    string concat = pattern + "$" + text;
    int l = concat.length();

    int Z[l];
    getZarr(concat, Z);

    for (int i = 0; i < l; ++i)
    {
        if (Z[i] == pattern.length())
        {
            found.push_back((int)(i - pattern.length() -1));
            cnt++;
        }
    }
    return found;
}

void getZarr(string str, int Z[])
{
    int n = str.length();
    int L, R, k;

    L = R = 0;
    for (int i = 1; i < n; ++i)
    {
        if (i > R)
        {
            L = R = i;

            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        }
        else
        {

            k = i-L;

            if (Z[k] < R-i+1)
                Z[i] = Z[k];

            else
            {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}

int main()
{
    string sample, pattern, buf;
    cin >> sample >> pattern;

    buf = sample;
    while (sample.size() < pattern.size())
        sample += buf;

    buf = sample + sample;

    int slen, plen;
    slen = buf.size();
    plen = pattern.size();

    auto found = search(buf, pattern);

    vector<bool> edge (sample.size(), false);

    FOR(0, cnt)
        if (found[i] >= sample.length())
            break;
        else
            edge[found[i]] = true;

    vector<bool> visited(sample.length(), false);
    vector<long long>  distt(sample.length(), 0);
    long long ans =0;

    FOR (0, sample.length())
    {
        if (visited[i] || !edge[i])
            continue;
        long long start = i, res =i, d=0;
        while (edge[res])
        {
            visited[res] = true;
            res = (res + pattern.length()) % sample.length();
            d++;

            if (res == start)
            {
                cout << -1 ;
                return 0;
            }
            else if (visited[res])
            {
                d+= distt[res];
                break;
            }
        }
        distt[start] = d;
        ans = max(d, ans);
    }

    cout << ans;
}




Measured memory_bytes: 31488