#include <bits/stdc++.h>
#define rep(i,sz) for (int i = 0; i < (sz); ++i)
const int INF = 1001001001;
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
struct Z_algorithm
{
    vector< int > prefix;
    
    void build(const string &s)
    {
    prefix.assign(s.size(), 0);
    for(int i = 1, j = 0; i < s.size(); i++) {
        if(i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while(i + k < s.size() && s[k] == s[i + k]) ++k;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int) s.size();
    }
    
    int operator[](const int k) const
    {
    return (prefix[k]);
    }
    
    size_t size()
    {
    return(prefix.size());
    }
};
struct TopologicalSort{
    int n;
    vector<set<int> > G;
    vector<bool> used;
    vector<int> indeg,p;
    
    TopologicalSort(){}
    TopologicalSort(int sz):n(sz),G(n),used(n),indeg(n),p(0){}
    
    void add_edge(int s,int t){
        G[s].insert(t);
    }
    
    void bfs(int s){
        queue<int> q;
        q.push(s);
        used[s]=1;
        while(!q.empty()){
            int v=q.front();q.pop();
            p.push_back(v);
            for(int u:G[v]){
                indeg[u]--;
                if(indeg[u]==0&&!used[u]){
                    used[u]=1;
                    q.push(u);
                }
            }
        }
    }
    
    vector<int>  build(){
        fill(used.begin(),used.end(),0);
        fill(indeg.begin(),indeg.end(),0);
        
        for(int i=0;i<n;i++)
            for(int v:G[i]) indeg[v]++;
        
        for(int i=0;i<n;i++)
            if(indeg[i]==0&&!used[i]) bfs(i);
        
        return p;
    }
};
int main(){
    string s, t; cin >> s >> t;
    int sz = s.size(), tz = t.size();
    int a = sz;
    do {
        rep(i, sz) s.push_back(s[i]);
        a += sz;
    }while(a < tz*2);
    Z_algorithm str; str.build(t+s);
    bool flag = true;
    vector<int> p(sz);
    TopologicalSort ts(sz*2);
    rep(i, sz) {
        p[i] = str.prefix[i+tz];
        if(p[i]>=tz){
            flag = false;
        }
    }if(flag) {puts("0"); return 0;}
    rep(i, sz) p.push_back(p[i]);
    rep(i, sz*2) {
        if(p[i]>=tz){
            ts.add_edge(i,(i+tz)%(sz*2));
        }
    }
    auto pp=ts.build();
    reverse(pp.begin(),pp.end());
    vector<int> dp(sz*2,0);
    for(int v:pp)
        for(int u:ts.G[v])
            chmax(dp[v],dp[u]+1);
    int ans = *max_element(dp.begin(),dp.end());
    if(ans == 0) cout << -1;
    else cout << ans;
    /*vector<P> edges;
    bool flag = true;
    rep(i, sz) {
        if(p[i] >= tz) edges.emplace_back(i,(i+tz)%sz), flag = false;
    }
    if(flag) {puts("0"); return 0;}
    int m = edges.size();
    {// bellman-ford
        bool upd = true;
        int ans = 1, step = 0;
        while(upd) {
            upd = false;
            rep(i,m) {
                int a = edges[i].first;
                int b = edges[i].second;
                int newD = d[a] - 1;
                if(newD < d[b]) {
                    upd = true;
                    d[b] = newD;
                    ans = min(ans, d[b]);
                }
            }
            step++;
            if(step > sz){
                puts("-1");
                return 0;
            }
        }
        cout << -ans << endl;
    }*/
}



Measured memory_bytes: 120584