#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e7 + 5, M = 2 * N + 5;

vector<int> res;
void KMP(const string &s, const string &k){
    res.clear();
    if (k.empty())
        return ;
    vector<int> tmp(k.size(), 0);
    for (int i = 1, j = 0; i < k.size(); ++i){
        while (j && k[j] != k[i])
            j = tmp[j - 1];
        if (k[j] == k[i])
            ++j;
        tmp[i] = j;
    }
    for (int i = 0, j = 0; i < s.size(); ++i){
        while (j && k[j] != s[i])
            j = tmp[j - 1];
        if (k[j] == s[i])
            ++j;
        if (j == k.size())
            res.push_back(i - j + 1);
    }
}

int n, m;

string a, b;

int f(){
    n = res.size();
    int mx = 0;
    int len = a.size();
    vector<int> sum(len, 0);
    for(auto i : res){
        if(i - m >= 0)
            sum[i] = sum[i - m] + 1;
        else sum[i] = 1;
        mx = max(mx, sum[i]);        
    }
    return mx;
}


int main(){
    IO;
    cin >> a >> b;
    m = b.size();
    while(a.size() <= m)
        a += a;
    a += a;
    a += a;
    KMP(a, b);
    int hna = f();
    a += a;
    a += a;
    KMP(a, b);
    if(f() > hna)return cout << -1 << endl, 0;
    if(n == 0)return cout << n << endl, 0;
    cout << hna << endl;
}