#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;

//-------------------------------------------------
//--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]++;
        }
    }
};

using ull = unsigned long long;
const ull b = 9973;
const ull mod[2] = {1000000033, 1000000087};

struct RollingHash{
    int n;
    vector<ull> hash[2], pw[2];
    RollingHash(const string &s){
        n = s.size();
        for(int i=0; i<2; i++){
            hash[i].resize(n+1);
            pw[i].resize(n+1);
            hash[i][0] = 0;
            pw[i][0] = 1;
            for(int j=0; j<n; j++){
                pw[i][j+1] = (pw[i][j]*b)%mod[i];
                hash[i][j+1] = (hash[i][j]*b+s[j])%mod[i];
            }
        }
    }
    static vector<ull> getHash(const string &s){
        int m = s.size();
        vector<ull> ret(2);
        for(int i=0; i<2; i++){
            ret[i] = 0;
            for(int j=0; j<m; j++)
                ret[i] = (ret[i]*b+s[j])%mod[i];
        }
        return ret;
    }
    bool match(int l, int r, vector<ull> h){
        bool ret=true;
        for(int i=0; i<2; i++){
            ull val = hash[i][r]-hash[i][l]*pw[i][r-l]%mod[i];
            val = (val+mod[i])%mod[i];
            ret&=(val==h[i]);
        }
        return ret;
    }
};

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

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; int l=0;
    rep(i,n+m-1) u.pb(s[i%n]);
    RollingHash rh(u);
    auto h = RollingHash::getHash(t);
    UnionFind uf(n);
    rep(i,n){
        if (rh.match(i,i+m,h)){
            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