// 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], dp[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;

    }

}



inline int dfs(int x)

{

    int &ret=dp[x];

    if(~ret) return 1;

    ret=0;

    if(!mark[x]) return 1;

    ret=-2;

    if(dp[(x+M)%N]==-2) return 0;

    if(!dfs((x+M)%N)) return 0;

    ret=dp[(x+M)%N]+1;

    return 1;

}



int main()

{

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

    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();

    int ret=0;

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

    {

        if(!dfs(i))

        {

            ret=-1;

            break;

        }

        ret=max(ret, dp[i]);

    }

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

    return 0;

}

// baaab

//abaaba


// Faster C++ solution for the same problem (measured speedup: 9.513225892706199x):
#include <iostream>

#include <bits/stdc++.h>



using namespace std;

char s[500005],t[500005];

char st[2000000];

int pre[2000000];

bool ab[500005];

int cnt[500005],sy[500005];



int main()

{

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

    int slen = strlen(s);int tlen = strlen(t);

    int alen = slen+1;

    memcpy(st,s,sizeof(char)*slen);

    st[slen] = '#';



    while(alen-slen-1<max(2*slen,2*tlen)){

        memcpy(st+alen,t,sizeof(char)*tlen);

        alen+=tlen;

    }



    for (int i = 1; i < alen; i++) {

    int j = pre[i - 1];

    while (j > 0 && st[i] != st[j]) j = pre[j - 1];

    if (st[i] == st[j]) j++;

    pre[i] = j;

  }

    int tlen2 = 2*tlen;

    for(int i=1;i<=tlen;++i){

        if(pre[alen-i]==slen) {

            ab[(tlen2-i-slen%tlen+1)%tlen] = true;

        }

    }



    bool minf = false;

    for(int i=0;i<tlen&&!minf;++i){

        int ncnt = 1,j=i;

        while(ab[j]&&cnt[j]<ncnt){

            if(sy[j]==i+1){

                minf = true;break;

            }

            cnt[j]=ncnt++;

            sy[j] = i+1;

            j=(j+slen)%tlen;

        }

    }



    int ans = 0;

    for(int i=0;i<tlen;++i) ans = max(ans,cnt[i]);

    if(minf) ans = -1;

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

    return 0;

}