#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Rolling Hash
//-------------------------------------------------
using ull = unsigned long long;
using Hash = vector<ull>;

const int M_NUM = 2;
const ull mod[4] = {(ull)1e9+33,(ull)1e9+87,(ull)1e9+93,(ull)1e9+97};
const ull base = 9973;

class RollingHash
{
private:
    int n;
    vector<ull> _hash[4], _pow[4];
public:
    RollingHash(const string &s){
        n = s.size();
        for(int i=0; i<M_NUM; i++){
            _hash[i].resize(n+1); _hash[i][0] = 0;
            _pow[i].resize(n+1); _pow[i][0] = 1;
            for(int j=0; j<n; j++){
                _pow[i][j+1] = (_pow[i][j]*M_NUM)%mod[i];
                _hash[i][j+1] = (_hash[i][j]*M_NUM+s[j])%mod[i];
            }
        }
    }
    bool match(int l, int r, Hash h){
        bool ret=true;
        for(int i=0; i<M_NUM; i++){
            ull value = _hash[i][r]-(_hash[i][l]*_pow[i][r-l])%mod[i];
            value = (value+mod[i])%mod[i];
            ret&=(value==h[i]);
        }
        return ret;
    }
    vector<int> matches(Hash h, int w){
        vector<int> ret;
        for(int i=0; i<n-w+1; i++)
            if (match(i,i+w,h)) ret.push_back(i);
        return ret;
    }
    static Hash hash(const string &s){
        Hash ret(M_NUM);
        for(int i=0; i<M_NUM; i++)
            for(int j=0; j<s.size(); j++)
                ret[i]=(ret[i]*M_NUM+s[j])%mod[i];
        return ret;
    }
};

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    ::std::vector<int> par;
    ::std::vector<int> rank;
public:
    UnionFind(int n):par(n), rank(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]>rank[ry]){
            par[ry] = rx;
        }else{
            par[rx] = ry;
            if (rx==ry) rank[ry]++;
        }
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin>>s>>t;
    int n=s.size(), m=t.size();
    string u;
    rep(i,n+m-1) u+=s[i%n];
    RollingHash rh(u);
    Hash pat = RollingHash::hash(t);
    UnionFind uf(n);
    rep(i,n){
        if (rh.match(i,i+m,pat)){
            if (uf.same(i,(i+m)%n)){
                cout<<"-1\n";
                return 0;
            }
            uf.unite(i,(i+m)%n);
        }
    }
    int ans=0;
    unordered_map<int,int> cnt;
    rep(i,n){
        int r = uf.root(i);
        chmax(ans,cnt[r]++);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 57068