//#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
//struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
__attribute__((constructor))
void init(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
}
// random_device rd;
// mt19937 mt(rd());
// #include <boost/numeric/interval.hpp>
// #include <boost/numeric/interval/io.hpp>
// #include <boost/intrusive/rbtree.hpp>
// #include <boost/dynamic_bitset.hpp>
// #include <boost/geometry.hpp>
// #include <boost/geometry/geometries/linestring.hpp>
// #include <boost/geometry/geometries/polygon.hpp>
// #include <boost/geometry/geometries/point_xy.hpp>
// #include <boost/math/tools/minima.hpp>
// using boost::math::tools::brent_find_minima;
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<256>> cdouble;
// typedef mp::cpp_int cint;

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
template<typename T=long long>using pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T=long long>using pbds_map=tree<T,T,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T=long long>using pqueue =__gnu_pbds::priority_queue<T, less<T>,rc_binomial_heap_tag>;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define _output(v) do{bool f=0;rep(i,v.size()){cout<<(f?" ":"");if(v[i]>INF/2)cout<<"INF";else cout<<v[i];f=1;}cout<<"\n";}while(0)
#define _output2(v) rep(j,v.size()){_output(v[j]);}
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define LINF 9223372036854775807
#define MOD 100000007
#define endl "\n"
template<typename T=lint>T in(){return *istream_iterator<T>(cin);}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
template<typename T=lint>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<typename T=lint>inline T add(T a,T b){return a+b;}
template<typename T=lint>inline T minq(T a,T b){return min(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};


struct rolling_hash{
    using u64 = std::uint_fast64_t;
    class hash_string{
        public:
        u64 digit;
        vector<u64> hash;
        rolling_hash* par;
        u64 base,mod_num;
        vector<u64> mod;
        hash_string(){cerr<<"err"<<endl;}
        hash_string(rolling_hash* par):digit(0),par(par),base(par->base),mod_num(par->mod_num),mod(par->mod){hash.resize(mod_num,0);}
        hash_string(rolling_hash* par,u64 digit,vector<u64> hash):digit(digit),hash(hash),par(par),base(par->base),mod_num(par->mod_num),mod(par->mod){}
        hash_string operator +(char c){
            return hash_string(*this)+=c;
        }
        hash_string operator +=(char c){
            vector<u64>hashTable(mod_num);
            rep(i,mod_num)this->hash[i]=(hash[i]*base+u64(c))%mod[i];
            this->digit++;
            return *this;
        }
        hash_string operator +(hash_string s){
            return hash_string(*this)+=s;
        }
        hash_string operator +=(hash_string s){
            vector<u64>hashTable(mod_num);
            rep(i,mod_num)this->hash[i]=(hash[i]*mod_pow(base,s.digit,mod[i])+s.hash[i])%mod[i];
            this->digit+=s.digit;
            return *this;
        }
        hash_string operator -(hash_string s){
            vector<u64>hashTable(mod_num);
            rep(i,mod_num)hashTable[i]=(hash[i]+mod[i]-(s.hash[i]*mod_pow(base,digit-s.digit,mod[i]))%mod[i])%mod[i];
            return hash_string(par,digit-s.digit,hashTable);
        }
        hash_string operator -(char c){
            vector<u64>hashTable(mod_num);
            rep(i,mod_num)hashTable[i]=(hash[i]+mod[i]-(u64(c)*mod_pow(base,digit-1,mod[i]))%mod[i])%mod[i];
            return hash_string(par,digit-1,hashTable);
        }
        hash_string operator *(u64 num){
            u64 exp=num;
            auto res=hash_string(par);
            auto x=*this;
            while(exp){
                if(exp%2)res=res+x;
                x=x+x;
                exp/=2;
            }
            return res;
        }
        bool operator ==(hash_string s){
            return hash==s.hash;
        }
        private:
        inline u64 mod_pow(u64 x,const u64& y,const u64& _mod){
            if(par->cache[_mod].count(y)){return par->cache[_mod][y];}
            u64 exp=y;
            u64 res=1;
            while(exp){
                if(exp%2){
                    res*=x;
                    res%=_mod;
                }
                x*=x;
                x%=_mod;
                exp/=2;
            }
            return par->cache[_mod][y]=res;
        }
    };
    vector<hash_string>hash;
    const u64 base=10007,mod_num=3;
    const vector<u64> mod={1000000007,999999937,998244353};
    unordered_map<u64,unordered_map<u64,u64>>cache;
    rolling_hash(){
        hash.resize(1,hash_string(this));
    }
    rolling_hash(string s){
        hash.resize(s.size()+1,hash_string(this));
        repi(i,1,s.size()+1)hash[i]=hash[i-1]+s[i-1];
    }
    hash_string operator()(int l,int len=-1){
        if(len==-1)return hash[hash.size()-1]-hash[l];
        else return hash[l+len]-hash[l];
    }
    hash_string operator()(){
        return hash[hash.size()-1];
    }
};

lint bs(lint mn=0,lint mx=INF,function<bool(lint)> func=[](lint x){return true;}) {
    lint left = mn-1;
    lint right =mx;
    while (right - left > 1) {
        lint mid =(right+left)/2;
        if (!func(mid)) right = mid;
        else left = mid;
    }
    return left;
}

struct UF{
    public:
    vector<lint> par;
    vector<lint> rank;
    lint _s;
    UF(lint size){
        _s=size;
        par.resize(size);
        rep(i,size)par[i]=i;
        rank.resize(size,0);
    }
    bool unite(lint x,lint y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(rank[x]<rank[y])swap(x,y);
        if(rank[x]==rank[y])rank[x]++;
        par[y]=x;
        _s--;
        return true;
    }
    lint root(lint x){
        while(x!=par[x]){
            x=par[x]=par[par[x]];
        }
        return x;
    }
    bool same(lint x, lint y) {
        return root(x) == root(y);
    }
    lint size(){
        return _s;
    }
};

int main(){
    string s,t;
    cin>>s>>t;
    auto a=rolling_hash();
    auto sh=a();
    rolling_hash th(t);
    vector<bool>tmp(s.size());
    rep(i,t.size()){
        sh=sh+s[i%s.size()];
    }
    rep(i,s.size()){
        tmp[i]=(sh==th());
        sh=sh+s[(t.size()+i)%s.size()]-s[i];
    }
    UF uf(s.size());
    rep(i,s.size()){
        auto j=(i+t.size())%s.size();
        if(tmp[i]&&tmp[j]){
            if(uf.same(i,j)){
                cout<<-1<<endl;
                return 0;
            }
            uf.unite(i,j);
        }
    }
    unordered_map<int,int>m;
    rep(i,s.size()){
        if(tmp[i])m[uf.root(i)]++;
    }
    int ans=0;
    for(auto d:m){
        chmax(ans,d.second);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 81072