#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<(n);++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#ifndef ONLINE_JUDGE
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
#else
#define pr(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#endif
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

vector<lli> z_function(string &s) {
    lli n=s.length();vector<lli> z(n);
    for (lli 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;
}
vi getpos(string text,string pattern){
    string temp=pattern+"@"+text;vi ans;
    vi zz=z_function(temp);//pr(zz);
    for(lli i=pattern.length()+1;i<=temp.length();i++){
        if(zz[i]==pattern.length())ans.EB(i-(lli)pattern.length()-1);
    }
    return ans;
}

graph g;

vi topo;
bool toposort(int n){
    queue<int> pq;int inndeg[n];mset(inndeg,0);
    rep(i,0,n-1){for(auto v:g[i])inndeg[v]++;}
    rep(i,0,n-1){if(inndeg[i]==0)pq.push(-i);}
    while(!pq.empty()){int tt=-pq.front();pq.pop();topo.EB(tt);
    for(auto v:g[tt]){inndeg[v]--;if(inndeg[v]==0)pq.push(-v);}}
    if(sz(topo)<n)return 0;else return 1;
}

void solve(){
    string s,t;
    cin>>s>>t;
    string temp="";
    while(temp.length()<t.length()){
        temp+=s;
    }
    vi pos=getpos(temp+temp,t);
    int n=temp.length();
    int ismatch[n];mset(ismatch,0);
    for(auto v:pos)if(v<n)ismatch[v]=1;
    g.resize(n);
    for(int i=0;i<n;i++){
        if(ismatch[i]==1){
            g[i].EB((i+t.length())%n);
        }
    }

    int dp[n];mset(dp,0);

    bool x=toposort(n);
    if(!x){
        cout<<-1<<endl;return;
    }else{
        for(int i=n-1;i>=0;i--){
            int cur=topo[i];
            if(ismatch[cur]==1){
                dp[cur]=1+dp[(cur+t.length())%n];
            }else{
                dp[cur]=0;
            }
        }
        cout<<*max_element(dp,dp+n)<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //cout<<fixed<<setprecision(15);
    //clock_t begin = clock();
    pre();lli _t=1;//cin>>_t;
    for(lli i=1;i<=_t;i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    // clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}

Measured memory_bytes: 80908