#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,t,co;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

template<typename T,T MOD, T MOD2, T MOD3, T B>
struct RollingHash{
    vector<T> hash, hash2, hash3, p, q, r;
    RollingHash(){}
    RollingHash(const string &s){
        int n=s.size();
        hash.assign(n+1,0);
        hash2.assign(n+1,0);
        hash3.assign(n+1,0);
        p.assign(n+1,1);
        q.assign(n+1,1);
        r.assign(n+1,1);
        rep(i,n){
            hash[i+1]=(hash[i]*B+s[i])%MOD;
	        hash2[i+1]=(hash2[i]*B+s[i])%MOD2;
	        hash3[i+1]=(hash3[i]*B+s[i])%MOD3;
            p[i+1]=p[i]*B%MOD;
            q[i+1]=q[i]*B%MOD2;
            r[i+1]=r[i]*B%MOD3;
        }
    }

    void add(string &t){
	    const int oldLen=hash.size();
	    hash.resize(hash.size()+t.size(),0);
	    hash2.resize(hash.size()+t.size(),0);
	    hash3.resize(hash.size()+t.size(),0);
	    p.resize(hash.size()+t.size(),1);
	    q.resize(hash.size()+t.size(),1);
	    r.resize(hash.size()+t.size(),1);
	    rep(i,Size(t)){
	        hash[oldLen+i]=(hash[oldLen-1+i]*B+t[i])%MOD;
	        hash2[oldLen+i]=(hash2[oldLen-1+i]*B+t[i])%MOD2;
	        hash3[oldLen+i]=(hash3[oldLen-1+i]*B+t[i])%MOD3;
	        p[oldLen+i]=p[oldLen+i-1]*B%MOD;
	        q[oldLen+i]=q[oldLen+i-1]*B%MOD2;
	        r[oldLen+i]=r[oldLen+i-1]*B%MOD3;
	    }
    }
  
  //S[l, r)
  pair<T,pair<T,T>> find(int l,int R){
	if(l==R)return {0,{0,0}};
    T res=hash[R]+MOD-hash[l]*p[R-l]%MOD;		
    res%=MOD;
    T ret=hash2[R]+MOD2-hash2[l]*q[R-l]%MOD2;	
    ret%=MOD2;
	T rel=hash3[R]+MOD3-hash3[l]*r[R-l]%MOD3;	
    rel%=MOD3;
	return {res,{ret,rel}};
  }
};

struct UnionFind{
	std::vector<int> data;
	
	UnionFind(int n){
		data.assign(n,-1);
	}
	
	void unite(int x, int y){
		x=find(x); y=find(y);
		if(x==y) return;
		if(data[x]>data[y]) swap(x,y);
		data[x]+=data[y];
		data[y]=x;
	}
	
	int find(int k){
		if(data[k]<0) return k;
		return data[k]=find(data[k]);
	}
 
	int size(int k) {
		return -data[find(k)];
	}
 
	bool same(int x, int y){
		return find(x)==find(y);
	}
};

int main(void){
        cin.tie(0);
        cout.tie(0);
    ios::sync_with_stdio(false);

    cin>>s>>t;
    n=Size(s);

    const ll MOD1=1e9+7;
	const ll MOD2=1e9+9;
	const ll MOD3=1234567891;
	const ll B=1777771;
	using RH=RollingHash<ll,MOD1,MOD2,MOD3,B>;

    co=s;
    while(1){
        if(Size(s)>Size(t))break;
        s+=co;
    }
    s+=s;
    s+=s;

    UnionFind uf(Size(s)+100);

    RH A(s);
    RH BB(t);
    auto Y=BB.find(0,Size(t));
    rep(i,Size(s)-Size(t)+1){
        auto X=A.find(i,i+Size(t));
        if(X==Y&&!uf.same(i%n,(i+Size(t))%n)){
            uf.unite(i%n,(i+Size(t))%n);
        }
    }
    rep(i,n){
        ans=max(ans,(ll)uf.size(i));
    }

    ll fl1=0,fl2=0;
    rep(i,Size(s)-Size(t)+1){
        auto X=A.find(i,i+Size(t));
        if(X==Y)cnt++,i+=Size(t)-1;
        else cnt=0;
        fl1=max(fl1,cnt);
    }
    s+=s;
    RH AA(s);
    cnt=0;
    rep(i,Size(s)-Size(t)+1){
        auto X=AA.find(i,i+Size(t));
        if(X==Y)cnt++,i+=Size(t)-1;
        else cnt=0;
        fl2=max(fl2,cnt);
    }
    if(fl1==fl2)Cout(ans-1);
    else Cout(-1);
    return 0;
}


Measured memory_bytes: 613096