#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P; typedef complex<double> com;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
const int mod = 1e9+7; //998244353;
struct Mint {
    int val;
    Mint inv() const {
        int tmp, a = val, b = mod, x = 1, y = 0;
        while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
        return Mint(x);
    }
public:
    Mint() :val(0) {}
    Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
    int mtoi() { return this->val; }
    Mint pow(ll t) { Mint res = 1; while(t){if(t&1)res *= *this;*this *= *this;t >>= 1;}return res; }
    Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
    Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
    Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
    Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
    bool operator==(const Mint& x) const { return val == x.val; }
    bool operator!=(const Mint& x) const { return val != x.val; }
    bool operator<(const Mint& x) const { return val < x.val; }
    bool operator<=(const Mint& x) const { return val <= x.val; }
    bool operator>(const Mint& x) const { return val > x.val; }
    bool operator>=(const Mint& x) const { return val >= x.val; }
    Mint operator+(const Mint& x) const { return Mint(*this) += x; }
    Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
    Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
    Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx) {
        Fact.resize(maxx + 1,Mint(1)); Finv.resize(maxx + 1); rep(i, 0, maxx)Fact[i + 1] = Fact[i] * Mint(i + 1);
        Finv[maxx] = Mint(1) / Fact[maxx]; rrep(i, maxx, 0)Finv[i - 1] = Finv[i] * Mint(i);
    }
    Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
    Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
    Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};
class UnionFind {
    vector<int> par;
public:
    UnionFind(int n) { par = vector<int>(n, -1); }
    int root(int a) { if(par[a] < 0) return a; else return par[a] = root(par[a]); }
    int size(int a) { return -par[root(a)]; }
    void connect(int a,int b) {a=root(a),b=root(b); if(size(a)<size(b))swap(a,b); par[a]+=par[b],par[b]=a;}
};
struct edge { int u, v, cost; }; bool cmp(edge& e,edge& f){return e.cost<f.cost;}
vector<ll> dijkstra(vector<vector<edge>> Grp, int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    vector<ll> dist(Grp.size(), INF); dist[s] = 0; que.push({0, s});
    while (!que.empty()) {
        P p = que.top(); que.pop(); int v = p.second; if (dist[v] < p.first) continue;
        for(edge e:Grp[v])if(chmin(dist[e.v],dist[v]+e.cost))que.push({dist[e.v], e.v});
    } return dist;
}
ll merge_cnt(vector<int> a) {
    int n = a.size(), ai = 0, bi = 0, ci = 0; if (n <= 1) return 0; ll cnt = 0; 
    vector<int> b(a.begin(), a.begin() + n / 2), c(a.begin() + n / 2, a.end()); cnt += merge_cnt(b) + merge_cnt(c);
    while (ai < n) {if(bi<b.size()&&(ci==c.size()||b[bi]<=c[ci]))a[ai++]=b[bi++]; else cnt+=n/2-bi,a[ai++]=c[ci++];} 
    return cnt;
}
//template end

struct RollingHash {

    ll base1;
    ll base2;
    ll mod1;
    ll mod2;
    vector<ll> hash1;
    vector<ll> hash2;
    vector<ll> pow1;
    vector<ll> pow2;

    RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

    void init(const string &s) {
        int n = s.size();

        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);

        for(int i=0;i<n;i++) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }

    P get(int l,int r) {
        ll t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        ll t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }
};

int main() {
    string s,t,u; cin>>s>>t; u=s;
    while(s.size()<t.size())s+=u;
    int n=s.size(),m=t.size();
    s+=s;
    RollingHash rol,rol2;
    rol.init(s),rol2.init(t);
    UnionFind uni(n);
    rep(i,0,n){
        if(rol.get(i,i+m)==rol2.get(0,m)){
            if(uni.root(i)==uni.root((i+m)%n)){
                printf("-1"); return 0;
            }
            uni.connect(i,(i+m)%n);
        }
    }
    int ans=1;
    rep(i,0,n)chmax(ans,uni.size(i));
    printf("%d\n",ans-1);
    return 0;
}


Measured memory_bytes: 85300