// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

//万合以致，向阳而生——背叛时代，忠于时间//

#pragma GCC optimize(3,"Ofast","inline")

typedef long long ll;

typedef pair<int,int> pi;

typedef vector<int> vi;

typedef unsigned long long ull;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define forn(i, n) for(register int i=0; i<n; i++)

#define Forn(i, n) for(register int i=1; i<=n; i++)

#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)

#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)

#define mid l+r>>1

#define lid id<<1|1

#define rid (id<<1)+2

#define lson lid, l, mid

#define rson rid, mid, r



inline int in()

{

    char c=getchar();

    int neg=1, x=0;

    while(!isdigit(c)) (c=='-')?neg=-1, c=getchar():c=getchar();

    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48), c=getchar();

    return neg*x;

}

inline int lcm(int a, int b){return a*b/__gcd(a, b);}



const int MAX=20e5+5;



int N, M, ret, ptr, mark[MAX], fail[MAX], cnt[MAX];

char tt[MAX];

set<int> tmp;

string s, t;

vi v;



inline void kmp()

{

    fail[0]=ptr=-1;

    Forn(i, M)

    {

        while(ptr>-1&&t[ptr]!=t[i-1]) ptr=fail[ptr];

        fail[i]=++ptr;

    }

    

    ptr=0;

    forn(i, s.size())

    {

        while(ptr>-1&&s[i]!=t[ptr])

            ptr=fail[ptr];

        ptr++;

        if(ptr>=M) mark[i-M+1]=1;

    }

}



int main()

{

    memset(cnt, -1, sizeof(cnt));

    scanf("%s", tt); s=tt;

    scanf("%s", tt); t=tt;

    while(s.size()<t.size()) s+=s;

    N=s.size(), M=t.size();

    s+=s;

    

    kmp();

    forn(i, N) if(cnt[i]==-1)

    {

        int p=i, c=0;

        tmp.clear();

        while(mark[p])

        {

            if(tmp.count(p))

            {

                puts("-1");

                return 0;

            }

            if(~cnt[p])

            {

                c=cnt[p];

                break;

            }

            v.pb(p), tmp.insert(p);

            p=(p+M)%N;

        }

        if(!v.size()) cnt[i]=0;

        else

        {

            c++;

            while(v.size())

                cnt[v.back()]=c,

                c++, v.pop_back();

            ret=max(ret, c-1);

        }

    }

    printf("%d\n", ret);

    return 0;

}

// baaab

//abaaba


// Faster C++ solution for the same problem (measured speedup: 9.294978834938092x):
#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;

}