#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// https://github.com/beet-aizu/library/blob/master/string/knuth_morris_pratt.cpp
// longest prefix suffix matching of [0, i)
vector<int> KMPTable(const string &s){
    int n = s.size();
    vector<int> kmp(n+1, -1), mp(n+1, -1);
    for(int i = 0, j = -1; i < n; i++){
        while(~j && s[i] != s[j]) j = kmp[j];
        kmp[i+1] = mp[i+1] = ++j;
        if(i + 1 < n && s[i+1] == s[j]) kmp[i+1] = kmp[j];
    }
    return mp;
}
// smallest d s.t. s[x] == s[x + d] for all x
vector<int> minimum_period(const string &s){
    int n = s.size();
    vector<int> mp = KMPTable(s);
    for(int i = 1; i < n; i++) mp[i] = i - mp[i];
    return mp;
}
// positions for s that match t
vector<int> KMPSearch(const string &s,const string &t){
    int n = s.size(), m = t.size();
    vector<int> kmp = KMPTable(t);

    vector<int> res;
    int i = 0, j = 0;
    while(i + j < n){
        if(t[j] == s[i+j]){
            if(++j != m) continue;
            res.emplace_back(i);
        }
        i += j - kmp[j];
        j = max(kmp[j], 0);
    }
    return res;
}

struct UnionFind{
    // par[i] parent. if i == par[i] i is root
    vector<ll> par;
    // sizes[i] sizeof tree i if i is root
    vector<ll> sizes;

    UnionFind(ll n): par(n), sizes(n, 1){
        // init: all node is root i
        rep(i, n) par[i] = i;
    }

    // find root of x
    ll find(ll x){
        if (x == par[x])
            return x;
        return par[x] = find(par[x]); // recursive, editing root
    }

    // merge x, y
    void unite(ll x, ll y){
        // root
        x = find(x);
        y = find(y);

        // do not merge if same tree
        if (x == y)
            return;

        // force size x > y
        if (sizes[x] < sizes[y])
            swap(x, y);

        // unite: x is parent of y
        par[y] = x;
        sizes[x] += sizes[y];
    }

    // x, y same root
    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    // size of tree containing x
    ll size(ll x){
        return sizes[find(x)];
    }
};


int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll ns = SZ(s), nt = SZ(t);
    string s2;
    while(SZ(s2) < ns+nt-1){
        s2 += s;
    }
    vi found = KMPSearch(s2, t);
    dump(found);
    UnionFind uf(ns);
    for(auto&& e: found){
        if(e < ns){
            if(uf.same(e, (e+nt)%ns)){
                cout << -1 << endl;
                return 0;
            }
            uf.unite(e, (e+nt)%ns);
        }
    }
    dump(uf.sizes);
    cout << *max_element(ALL(uf.sizes))-1 << endl;
    return 0;
}

Measured memory_bytes: 14592