#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://qiita.com/Gaccho/items/dc312fb5a056505f0a9f
struct Rand{
    mt19937_64 mt;
    random_device rd;
    Rand(){ mt.seed(rd()); }
    void seed(){ mt.seed(rd()); }
    void seed(const ull seed_){ mt.seed(seed_); }
    
    // x1.5 slower than prepared uid
    // 64bit
    ull operator()(){
        return mt();
    }
    // int [0, max)
    ll operator()(const ll max_){
        uniform_int_distribution<> uid(min<ll>(0, max_-1), max<ll>(0, max_-1));
        return uid(mt);
    }
    // int [min, max]
    ll operator()(const ll min_, const ll max_){
        uniform_int_distribution<> uid(min(min_, max_), max(min_, max_));
        return uid(mt);
    }
    // real [0, max)
    ld operator()(const ld max_){
        uniform_real_distribution<> uid(min<ld>(0, max_), max<ld>(0, max_));
        return uid(mt);
    }
    // real [min, max)
    ld operator()(const ld min_, const ld max_){
        uniform_real_distribution<> uid(min(min_, max_), max(min_, max_));
        return uid(mt);
    }
};
static thread_local Rand rnd;

// Rolling hash with mod 2^64-1
// https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
// https://ei1333.github.io/luzhiled/snippets/string/rolling-hash.html
struct RollingHash{
    static const vector<ull> primes;
    static const ull base, MASK30, MASK31, RHMOD;
    vector<ull> hash, pow;
    inline ull calcmod(ull val) const{
        val = (val & RHMOD) + (val >> 61);
        if (val > RHMOD) val -= RHMOD;
        return val;
    }
    inline ull mulmod(ull a, ull b) const{
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        ull midu = mid >> 30;
        ull midd = mid & MASK30;
        return calcmod(au * bu * 2 + midu + (midd << 31) + ad * bd);
    }
    RollingHash(const string &s){
        int n = s.size();
        hash.assign(n+1, 0);
        pow.assign(n+1, 0);
        pow[0] = 1;
        for(int i = 0; i < n; i++) {
            pow[i+1] = mulmod(pow[i], base);
            hash[i+1] = mulmod(hash[i], base) + s[i];
            if(hash[i+1] >= RHMOD) hash[i+1] -= RHMOD;
        }
    }
    ull get(int l, int r) const{
        ull ret = hash[r] + RHMOD - mulmod(hash[l], pow[r-l]);
        if(ret >= RHMOD) ret -= RHMOD;
        return ret;
    }
    ull connect(ull h1, int h2, int h2len) const{
        ull ret = mulmod(h1, pow[h2len]) + h2;
        if(ret >= RHMOD) ret -= RHMOD;
        return ret;
    }
    int LCP(const RollingHash& b, int l1, int r1, int l2, int r2) {
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while(high - low > 1) {
            int mid = (low + high) >> 1;
            if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
            else high = mid;
        }
        return low;
    }
};
const vector<ull> RollingHash::primes{
    9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883,
    9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973
};
const ull RollingHash::base = RollingHash::primes[rnd(ll(RollingHash::primes.size()))];
const ull RollingHash::MASK30 = (1ul << 30) - 1;
const ull RollingHash::MASK31 = (1ul << 31) - 1;
const ull RollingHash::RHMOD = (1ul << 61) - 1;

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;
    }
    RollingHash rs(s2);
    RollingHash rt(t);
    //vi found = KMPSearch(s2, t);
    vi found(ns, 0);
    rep(i, ns){
        found[i] = (rs.get(i, i+nt) == rt.get(0, nt));
    }
    dump(found);
    UnionFind uf(ns);
    rep(i, ns){
        if(found[i] == 1){
            if(uf.same(i, (i+nt)%ns)){
                cout << -1 << endl;
                return 0;
            }
            uf.unite(i, (i+nt)%ns);
        }
    }
    dump(uf.sizes);
    cout << *max_element(ALL(uf.sizes))-1 << endl;
    return 0;
}

Measured memory_bytes: 43848