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

// https://atcoder.jp/contests/abc135/submissions/6583759 を参考

int main() {
    string s, t;
    cin >> s >> t;

    // KMP法でtをいっぱい並べた文字列の先頭から何文字が含まれるかを調べる
    string tk, sk;
    while(tk.size() < s.size() + t.size()){
        tk += t;
    }
    while(sk.size() < s.size() + t.size() * 2){
        sk += s;
    }
    // sk.size() > tk.size() >= 2 * t.size()

    // KMP_table を作成
    int n = tk.size();
    vector<int> table(n + 1, -1);
    int j = -1;
    for(int i = 0; i < n; ++i){
        while(j >= 0 && tk[i] != tk[j]){
            j = table[j];
        }
        j++;
        table[i+1] = j;
    }

    // KMP法
    int cur = 0, mx = 0;
    for(char x : sk){
        while(cur >= 0 && tk[cur] != x){
            cur = table[cur];
        }
        ++cur;
        mx = max(mx, cur);
        if(cur == n) break;
    }

    int ans = -1;
    if(mx < (s.size() + t.size())){
        ans = mx / t.size();
    }
    cout << ans << "\n";
    return 0;
}