#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

string s, t;
int b[8000010], dp[8000010];
vector<int> a;

void kmpPreprocess() {
    b[0] = 0;
    FOR(i,1,SZ(t)-1) {
        int k = b[i-1];
        while (k > 0 && t[k] != t[i]) k = b[k-1];
        if (t[k] == t[i]) b[i] = k+1;
        else k = 0;
    }
}

void kmpSearch() {
    int j = 0;
    FOR(i,0,SZ(s)-1) {
        while (j > 0 && s[i] != t[j]) j = b[j-1];
        if (s[i] == t[j]) j++;
        else j = 0;
        if (j == SZ(t)) {
            a.emplace_back(i-SZ(t)+2);
            j = b[j-1];
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s >> t;
    while (SZ(s) <= SZ(t)) s = s + s;
    s = s + s + s;
    kmpPreprocess();
    kmpSearch();
    if (SZ(a) == 0) {
        cout << 0;
        return 0;
    }
    int res = 1;
    FOR(i,0,SZ(a)-1) {
        int e = a[i] - SZ(t);
        if (i == 0) {
            dp[i] = 1;
            continue;
        }
        int dau = 0, cuoi = i-1;
        while (dau <= cuoi) {
            int mid = (dau + cuoi) / 2;
            if (a[mid] > e) cuoi = mid-1;
            else dau = mid+1;
        }
        if (cuoi >= 0 && cuoi <= i-1) {
            if (e == a[cuoi]) dp[i] = dp[cuoi] + 1;
            else dp[i] = 1;
        }
        else dp[i] = 1;
        res = max(res, dp[i]);
    }
    s = s + s;
    a.clear();
    kmpSearch();
    int res2 = 1;
    FOR(i,0,SZ(a)-1) {
        int e = a[i] - SZ(t);
        if (i == 0) {
            dp[i] = 1;
            continue;
        }
        int dau = 0, cuoi = i-1;
        while (dau <= cuoi) {
            int mid = (dau + cuoi) / 2;
            if (a[mid] > e) cuoi = mid-1;
            else dau = mid+1;
        }
        if (cuoi >= 0 && cuoi <= i-1) {
            if (e == a[cuoi]) dp[i] = dp[cuoi] + 1;
            else dp[i] = 1;
        }
        else dp[i] = 1;
        res2 = max(res2, dp[i]);
    }
    if (res2 > res) cout << -1;
    else cout << res;
    return 0;
}


Measured memory_bytes: 59592