#include <bits/stdc++.h>
using namespace std;

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i < (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << setprecision(20);
    }
} iosetup;

// SOLVE

struct RollingHash{ // ローリングハッシュ法
private:
    static const int mod1 = 1031326447, mod2 = 993766717;
    static const int base1 = 281, base2 = 383;
    vector<long long> hash1, hash2, pow1, pow2;
public:
    string str;
    RollingHash(const string& s) : str(s) { // 初期化
        int sz = (int)s.size();
        hash1.assign(sz + 1, 0); hash2.assign(sz + 1, 0);
        pow1.assign(sz + 1, 1); pow2.assign(sz + 1, 1);
        for(int i = 0; i < sz; i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    inline pair<long long, long long> get(int l, int r){ // get [l, r)
        long long res1 = (hash1[r] - hash1[l] * pow1[r - l]) % mod1;
        long long res2 = (hash2[r] - hash2[l] * pow2[r - l]) % mod2;
        if(res1 < 0)res1 += mod1; if(res2 < 0)res2 += mod2;
        return { res1, res2 };
    }
    inline int getLCP(int x, int y){ // LCP S[a:], S[b:]
        int len = min((int)size() - x, (int)size() - y) + 1;
        int l = 0, r = len;
        while(r - l > 1){
            int m = (l + r) >> 1;
            if(get(x, x + m) != get(y, y + m))r = m;
            else l = m;
        }
        return l;
    }
    inline void add_str(const string& s){ // string型を連結
        int ns = (int)str.size(), ms = (int)s.size();
        str += s;
        hash1.resize(ns + ms + 1); hash2.resize(ns + ms + 1);
        pow1.resize(ns + ms + 1); pow2.resize(ns + ms + 1);
        for(int i = ns; i < ns + ms; i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i - ns]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i - ns]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    inline void add_char(const char& c){ // char型を連結
        str += c;
        hash1.push_back((hash1.back() * base1 + c) % mod1);
        hash2.push_back((hash2.back() * base2 + c) % mod2);
        pow1.push_back((pow1.back() * base1) % mod1);
        pow2.push_back((pow2.back() * base2) % mod2);
    }
    inline void add_rh(const RollingHash& rh){ //Rolling Hash を連結
        add_str(rh.str);
    }
    inline char operator[](int i){ // i文字目を取得
        return str[i];
    }
    inline size_t size(){ // strのsizeを返す
        return str.size();
    }
};

struct UnionFind{ //素集合データ構造
private:
    vector<int> par;
public:
    UnionFind(int n): par(n, -1) {}
    int find(int x){
        if(par.at(x) < 0) return x;
        else return par.at(x) = find(par.at(x));
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(size(x) < size(y)) swap(x, y);
        par.at(x) += par.at(y);
        par.at(y) = x;
    }
    int size(int x){ return -par.at(find(x)); }
    bool same(int x, int y){ return find(x) == find(y); }
    void reset(int n){ par = vector<int>(n, -1); }
};

int main(){

    string s, T;
    cin >> s >> T;

    string S = "";
    while(S.size() < T.size())S += s;

    int sz = S.size(), tsz = T.size();
    UnionFind uni(sz);
    S += S;
    RollingHash rh1(S), rh2(T);
    rep(i, sz){
        if(rh1.get(i, i + tsz) == rh2.get(0, tsz)){
            int next = (i + tsz) % sz;
            if(uni.same(i, next)){
                cout << "-1\n";
                return 0;
            }
            uni.unite(i, next);
        }
    }

    int ans = 0;
    rep(i, sz)chmax(ans, uni.size(i) - 1);
    cout << ans << '\n';
    return 0;

}

Measured memory_bytes: 85704