#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);
    }
};
const ll mod1 = 100000000000031LL, mod2 = 1000000000000037LL,
         base1 = 256LL + (random_device()() % 64),
         base2 = 256LL + (random_device()() % 64);
struct RollingHash {
    int n;
    string s;
    vector<ll> hash1, hash2, pow1, pow2;
    RollingHash(const string &str) {
        s = str;
        n = str.length();
        hash1.resize(n + 10);
        hash2.resize(n + 10);
        pow1.resize(n + 10, 1);
        pow2.resize(n + 10, 1);
        for (int i = 0; i < n; i++) {
            hash1[i + 1] = (__uint128_t)(hash1[i] + s[i]) * base1 % mod1;
            hash2[i + 1] = (__uint128_t)(hash2[i] + s[i]) * base2 % mod2;
            pow1[i + 1] = (__uint128_t)pow1[i] * base1 % mod1;
            pow2[i + 1] = (__uint128_t)pow2[i] * base2 % mod2;
        }
    }
    pair<ll, ll> get(int l, int r) {
        ll t1 = (hash1[r] - (__uint128_t)hash1[l] * pow1[r - l] % mod1 + mod1) %
                mod1;
        ll t2 = (hash2[r] - (__uint128_t)hash2[l] * pow2[r - l] % mod2 + mod2) %
                mod2;
        return make_pair(t1, t2);
    }
};
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;
    }
    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)) {
            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: 91228