#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
char laz[maxn];
int pi[12*maxn],m,n;
string buf;
int prefix_function(const string &s,const string &t) {
    ///search t on s
    m=(int)t.length();
    n =(int)t.length()+(int)s.length()+1;
    buf=t+'#'+s;
    pi[0]=0;
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && buf[i] != buf[j])
            j = pi[j-1];
        if (buf[i] == buf[j])
            j++;
        pi[i] = j;
    }
    int ma=-1;
    for(int i=n-1;i>m;i--){
        pi[i]=(pi[i]==m?1:0);
        if(i+m<n&&pi[i]==1){
            pi[i]+=pi[i+m];
        }
        ma=max(ma,pi[i]);
    }
    return ma;
}
string s,t,a,ss,tt;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>ss>>t;
    s=ss;
    while((int)s.length()<=(int)t.length()+(int)ss.length()){
        s+=ss;
    }
    s+=ss;
    int c=prefix_function(s,t);
    if(c==-1){
       return cout<<"0",0;
    }
    s+=s;
    int cc=prefix_function(s,t);
    if(cc==c){
        return cout<<cc,0;
    }
    else{
        return cout<<-1,0;
    }
}
/*
    Good Luck
        -Lci70121
*/
