#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define ll long long
#define all(x) x.begin(),x.end()
using namespace std;
const int LIM = 1e7+3;
int last = 0;
string s,ss, cop;
int sz1, sz2;
std::vector<int> Indeces;
void computeLPSArray(string pat, int M, int* lps); 
  
// Prints occurrences of txt[] in pat[] 
bool isSubStrin(string txt, string pat) 
{ 
    bool Ok = false;
    int M = pat.size(); 
    int N = txt.size(); 
  
    // create lps[] that will hold the longest prefix suffix 
    // values for pattern 
    int lps[M]; 
  
    // Preprocess the pattern (calculate lps[] array) 
    computeLPSArray(pat, M, lps); 
  
    int i = 0; // index for txt[] 
    int j = 0; // index for pat[] 
    while (i < N) { 
        if (pat[j] == txt[i]) { 
            j++; 
            i++; 
        } 
  
        if (j == M) { 
            Indeces.push_back(i);
            Ok = true;
            j = lps[j - 1]; 
        } 
  
        // mismatch after j matches 
        else if (i < N && pat[j] != txt[i]) { 
            // Do not match lps[0..lps[j-1]] characters, 
            // they will match anyway 
            if (j != 0) 
                j = lps[j - 1]; 
            else
                i = i + 1; 
        } 
    } 
    return Ok;
} 
  
// Fills lps[] for given patttern pat[0..M-1] 
void computeLPSArray(string  pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
}
void getString(string &Cur, int last, int to)
{
    while(last<to)
        Cur+=cop, last++;
    while(to<last)
        Cur.erase(Cur.size()-sz2, sz2), last--;
}

bool vis[LIM+3];

int main(){
    cin >> s >> ss;
    bool Is = true;
    sz1 = s.size(); sz2 = ss.size();
    cop = s;
    while(sz1 < sz2)
      s += cop, sz1 = s.size();
    s += s; sz1 = s.size();
    s += s; sz1 = s.size();
    cop = ss;
    int last = 1;
    int Ans = 0, cnt = 0;
    isSubStrin(s,ss);
    for(int i =0;i<Indeces.size();i++)
    {
        if(vis[i])continue;
        cnt = 1;
        int st = Indeces[i];
        while(true)
        {
            int ind = lower_bound(all(Indeces), st+sz2)-Indeces.begin();
            //cout << ind << endl;
            if(ind == Indeces.size() or Indeces[ind] != st+sz2)break;
            vis[ind] = true; st = Indeces[ind]; cnt++;
        }
        Ans = max(Ans, cnt);
    }
    s += s;
    getString(ss, last, sz1/sz2 + 1);
    //cout << s << " " << ss << endl;
    if(isSubStrin(s,ss)){puts("-1");return 0;}
    cout << Ans << endl;
}

Measured memory_bytes: 80784