#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const long long INF = 1LL<<28;
const ll MOD = 1e9 + 7;

template<ll MOD> struct ModInt {
    ll value;
    ModInt() : value(0) {}
    ModInt(const long long& v) : value(v % MOD) {
        while ( value < 0 ) value += MOD;
    }

    ModInt<MOD> operator=(const ModInt& o) {
        value = o.value;
        return *this;
    }
    ModInt<MOD> operator+=(const ModInt& o) {
        value += o.value;
        if ( value >= MOD ) value -= MOD;
        return *this;
    }
    ModInt<MOD> operator-=(const ModInt& o) {
        value += MOD - o.value;
        if (value >= MOD ) value -= MOD;
        return *this;
    }
    ModInt<MOD> operator*=(const ModInt& o) {
        value *= o.value;
        value %= MOD;
        return *this;
    }
    ModInt<MOD> operator/=(const ModInt& o) {
        value *= inverse(o.value);
        value %= MOD;
        return *this;
    }

    ModInt<MOD> operator-() {
        return ModInt<MOD>(-value);
    }
    ModInt<MOD> operator+(const ModInt& o) {
        ModInt<MOD> r(*this);
        r += o;
        return r;
    }
    ModInt<MOD> operator-(const ModInt& o) {
        ModInt<MOD> r(*this);
        r -= o;
        return r;
    }
    ModInt<MOD> operator*(const ModInt& o) {
        ModInt<MOD> r(*this);
        r *= o;
        return r;
    }
    ModInt<MOD> operator/(const ModInt& o) {
        ModInt<MOD> r(*this);
        r /= o;
        return r;
    }
    bool operator==(const ModInt& o) {
        return value == o.value;
    }

    ModInt<MOD> pow(ll n) {
        ModInt<MOD> r = 1;
        ModInt<MOD> t = *this;
        while ( n > 0 ) {
            if ( n & 1 ) {
                r *= t;
            }
            t *= t;
            n >>= 1;
        }
        return r;
    }

private:
    long long gcd(long long a, long long b) {
        long long t;
        if ( a < 0 ) a = -a;
        if ( b < 0 ) b = -b;
        while ( b != 0 ) {
            t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    long long inverse(long long a) {
        long long b = MOD, x = 1, y = 0, s, t;
        while ( b != 0 ) {
            s = y;
            y = x - ( a / b ) * y;
            x = s;
            t = b;
            b = a % b;
            a = t;
        }
        long long r = x % MOD;
        if ( r < 0 ) r += MOD;
        return r;
    }
};

template<ll MOD> std::ostream& operator<< (std::ostream& os, const ModInt<MOD>& o) {
    os << o.value;
    return os;
}

using mint = ModInt<MOD>;

ll solve() {
    string S, T;
    cin >> S >> T;
    mint b = 1009;
    ll ss = S.size(), st = T.size();
    vector<mint> hs(ss);
    mint ht = 0, hs0 = 0, bt = 1;
    for ( int i = 0; i < st; i++ ) {
        ht = b * ht + mint(T[i]);
        hs0 = b * hs0 + mint(S[i % ss]);
        bt *= b;
    }
    for ( int i = 0; i < ss; i++ ) {
        hs0 = b * hs0  - bt * mint(S[i]) + mint(S[(st + i) % ss]);
        hs[(st + i) % ss] = hs0;
    }
    vector<ll> num(ss, -1);
    for ( ll j = 0; j < ss; j++ ) {
        ll i = 0;
        while ( hs[(j+i*st) % ss] == ht ) {
            i++;
            if ( i > 0 && i * st % ss == 0 ) num[(j+i*st) % ss] = INF;
            if ( num[(j+i*st) % ss] != -1 ) break;
        }
        ll len = 0;
        if ( num[(j+i*st) % ss] != -1 ) {
            len = num[(j+i*st) % ss];
            if ( len != INF ) len++;
            i--;
        }
        while ( i >= 0 ) {
            num[(j+i*st) % ss] = len;
            if ( len != INF ) len++;
            i--;
        }
    }

    ll ans = 0;
    for ( int j = 0; j < ss; j++ ) {
        if ( ans < num[j] ) ans = num[j];
    }
    if ( ans == INF ) ans = -1;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9224