#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-10;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s,t;cin>>s>>t;
    string ss=s;
    while(ss.size()<t.size()){
        ss+=s;
    }
    s=ss;
    ss+=s;
    bool ok[s.size()];
    fill(ok,ok+s.size(),false);
    ll u=0;
    ll uu=0;
    ll m1=10009,m2=10007;
    ll ut=0,uut=0;
    rep(i,0,t.size()){
        (ut*=m1)%=mod;
        ut+=t[i];
        ut%=mod;
        (uut*=m2)%=mod5;
        uut+=t[i];
        uut%=mod5;
    }
    rep(i,0,t.size()){
        (u*=m1)%=mod;
        u+=ss[i];
        u%=mod;
        (uu*=m2)%=mod5;
        uu+=ss[i];
        uu%=mod5;
    }
    ll b1=1,b2=1;
    rep(i,0,t.size()){
        (b1*=m1)%=mod;
        (b2*=m2)%=mod5;
    }
    rep(i,0,s.size()){
        if(ut==u&&uut==uu)ok[i]=true;
        (u*=m1)%=mod;
        (u+=ss[i+t.size()])%=mod;
        u+=-(b1*ss[i])%mod+mod;
        u%=mod;
        (uu*=m2)%=mod5;
        (uu+=ss[i+t.size()])%=mod5;
        uu+=-(b2*ss[i])%mod5+mod5;
        uu%=mod5;
    }
    ll now=0;
    ll ans=0;
    ll cnt[s.size()];
    fill(cnt,cnt+s.size(),-1);
    rep(i,0,s.size()){
        now=i;
        int sum=0;
        if(ok[now]==false){
            cnt[now]=0;
            continue;
        }
        vector<int> v;
        while(ok[now]){
            if(sum*t.size()>s.size()*2){
                cout<<-1<<endl;
                return 0;
            }
            if(cnt[now]>=0){
                sum+=cnt[now];
                break;
            }
            v.push_back(now);
            sum++;
            now+=t.size();
            now%=s.size();
        }
        rep(j,0,v.size()){
            cnt[v[j]]=sum;
            sum--;
        }
    }
    rep(i,0,s.size())Max(ans,cnt[i]);
    cout<<ans<<endl;
    //rep(i,0,s.size())cout<<cnt[i]<<" ";
    //cout<<endl;
}






Measured memory_bytes: 14000