// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

V<ll> calc_prefix(const string &T) {
    V<ll> ret(T.size(), 0);
    ll cur_max_idx = 0;
    for(ll i = 1; i < T.size(); i++) {
        if(ret[i - cur_max_idx] < ret[cur_max_idx] - (i - cur_max_idx)) {
            ret[i] = ret[i - cur_max_idx];
        } else {
            ll j = max<ll>(0, ret[cur_max_idx] - (i - cur_max_idx));
            for(; i + j < T.size() && T[i + j] == T[j]; j++);
            ret[i] = j;
            cur_max_idx = i;
        }
    }
    ret[0] = T.size();
    return ret;
}

V<ll> same_idx(const string &S, const string &T) {
    V<ll> max_prefix(S.size());
    V<ll> max_prefix_t = calc_prefix(T);
    DEBUG(max_prefix_t);
    string SS = S;
    while(SS.size() < T.size() + S.size()) SS += S;
    ll cur_max_idx = 0;
    for(ll i = 0; i < S.size(); i++) {
        DEBUG(PLL(i, cur_max_idx));
        if(max_prefix_t[i - cur_max_idx] < max_prefix[cur_max_idx] - (i - cur_max_idx)) {
            max_prefix[i] = max_prefix_t[i - cur_max_idx];
        } else {
            ll j = max<ll>(0, max_prefix[cur_max_idx] - (i - cur_max_idx));
            for(; i + j < SS.size() && j < T.size() && SS[i + j] == T[j]; j++);
            max_prefix[i] = j;
            cur_max_idx = i;
        }
    }
    DEBUG(max_prefix);
    V<ll> ret;
    for(ll i = 0; i < S.size(); i++) if(max_prefix[i] == T.size()) ret.push_back(i);
    return ret;
}

const ll inf = 5e15;

int main() {
    string S, T;
    cin >> S >> T;
    auto idx_v = same_idx(S, T);
    V<ll> cnt_v(S.size(), 0);
    for(auto &&ele : idx_v) cnt_v[ele] = -1;
    DEBUG(idx_v);

    for(auto &&ele : idx_v) {
        if(cnt_v[ele] != -1) continue;
        ll cur_idx = ele;
        stack<ll> idx_stack;
        idx_stack.push(cur_idx);
        while(true) {
            cnt_v[cur_idx] = inf;
            cur_idx += T.size();
            cur_idx %= S.size();
            if(cnt_v[cur_idx] != -1) break;
            idx_stack.push(cur_idx);
        }
        while(idx_stack.size()) {
            cnt_v[idx_stack.top()] = cnt_v[cur_idx] + 1;
            cur_idx = idx_stack.top();
            idx_stack.pop();
        }
    }

    ll ans = *max_element(ALL(cnt_v));
    cout << (inf <= ans ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 16148