#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
const int N = 2e6 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;
const int BASE = 129;
inline int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
int pw[N];
int h[N];
bool good[N];
int dist[N];
void calc(int n, int m) {
    for (int i = 0; i < n; ++i) dist[i] = N;
    queue <int> q;
    for (int i = 0; i < n; ++i) {
        if (!good[i]) {
            dist[i] = 0;
            q.push(i);
        }   
    }   
    while (q.size()) {
        int p = q.front(); q.pop();
        int pr = ((p - m) % n + n) % n;
        if (dist[p] + 1 < dist[pr]) {
            dist[pr] = dist[p] + 1;
            q.push(pr);
        }   
    }   
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    pw[0] = 1;
    for (int i = 1; i < N; ++i) pw[i] = mod(pw[i - 1] * BASE);
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    while (s.size() < t.size()) s += s;
    s += s;
    for (int i = 0; i < s.size(); ++i) h[i + 1] = mod(h[i] * BASE + s[i]);
    int w = 0;
    for (int i = 0; i < m; ++i) w = mod(w * BASE + t[i]);
    for (int i = 0; i < n; ++i) {
        good[i] = mod(h[i + m] - h[i] * pw[m]) == w;
    }   
    calc(n, m);
    int ans = 0;
    for (int i = 0; i < n; ++i) ans = max(ans, dist[i]);
    if (ans == N) cout << "-1\n";
    else cout << ans << '\n';
}   