#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int dfs(int s,vector <bool> &visited,vector <int> &time_in,vector <int> &time_out,int &time,vector <int> &ans,set <int> &s2,int m,int n,bool &f);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    int temp=n;
    string temp2=s;
    while(n<m)
    {
        n+=temp;
        s+=temp2;
    }
    string fin=t+"#"+s+s;
    vector <int> v=z_function(fin);
    set <int> s2;
    for(int i=0;i<n;i++)
        if(v[i+m+1]==m)
            s2.insert(i);

        //for(auto i:s2)
         //   cout<<i<<" ";
        //cout<<endl;

    bool f=1;
    vector <bool> visited;
    visited.resize(n,0);
    vector <int> time_in,time_out;
    time_in.resize(n,-1);
    time_out.resize(n,-1);
    int time=0;
    vector <int> ans;
    ans.resize(n,0);
    for(int i=0;i<n;i++)
        if(!visited[i])
            dfs(i,visited,time_in,time_out,time,ans,s2,m,n,f);
    if(!f)
        cout<<"-1\n";
    else
    {
        int test=0;
        for(int i=0;i<n;i++){
            test=max(test,ans[i]);
           // cout<<ans[i]<<" ";
        }
        //cout<<endl;
        cout<<test<<endl;
    }
    
    
    return 0;   
}

int dfs(int s,vector <bool> &visited,vector <int> &time_in,vector <int> &time_out,int &time,vector <int> &ans,set <int> &s2,int m,int n,bool &f)
{//cout<<s<<endl;
    visited[s]=1;
    time_in[s]=++time;
    if(s2.count(s)==0){
        ans[s]=0;
        time_out[s]=++time;
        return 0;
    }
    int child=(s+m)%n;
    int ret;
    if(!visited[child])
        ret=dfs((s+m)%n,visited,time_in,time_out,time,ans,s2,m,n,f);

    else
    {
        if(time_out[child]==-1)
            f=0;
        else
            ret=ans[child];
    }

    time_out[s]=++time;
    ans[s]=ret+1;
    return ans[s];

}


 
 


Measured memory_bytes: 120020