#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
struct RollingHash {
    int n;
    string s;
    const ll mod1 = 1000000007LL, mod2 = 1000000009LL, mod3 = 999999937LL,
             base1 = 1007LL, base2 = 1009LL, base3 = 9973LL;
    vector<ll> hash1, hash2, hash3, pow1, pow2, pow3;
    RollingHash(const string &str) {
        s = str;
        n = str.length();
        hash1.resize(n + 10);
        hash2.resize(n + 10);
        hash3.resize(n + 10);
        pow1.resize(n + 10, 1);
        pow2.resize(n + 10, 1);
        pow3.resize(n + 10, 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;
            hash3[i + 1] = (hash3[i] + s[i]) * base3 % mod3;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
            pow3[i + 1] = pow3[i] * base3 % mod3;
        }
    }
    pair<ll, pair<ll, ll>> 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;
        ll t3 = (hash3[r] - hash3[l] * pow3[r - l] % mod3 + mod3) % mod3;
        return make_pair(t1, make_pair(t2, t3));
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    while (s.length() < n + m) {
        s += s;
    }
    // cout << s << endl;
    RollingHash hs(s), ht(t);
    vector<int> f(n), vis(n, -1);
    for (int i = 0; i < n; i++) {
        if (hs.get(i, i + m) == ht.get(0, m)) {
            // cout << i << endl;
            f[i] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!f[i] || vis[i] != -1) {
            continue;
        }
        int co = 0, id = i;
        vector<int> v;
        while (1) {
            v.push_back(id);
            co++;
            id += m;
            id %= n;
            if (f[id]) {
                if (id == i) {
                    cout << -1 << endl;
                    return 0;
                }
                if (vis[id] != -1) {
                    co += vis[id];
                    break;
                }
                vis[id] = 0;
            } else {
                break;
            }
        }
        vis[i] = co;
        chmax(ans, co);
    }
    cout << ans << endl;
}


Measured memory_bytes: 131164