#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>
#include <complex>
 
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
 
using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;
using std::complex;
 
using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;
typedef complex<double> cd;
 
ll min(ll a, ll b)
{
    if (a < b)
        return a;
    return b;
}
 
ll max(ll a, ll b)
{
    if (a > b)
        return a;
    return b;
}
 
namespace MySpace{
    struct Small_Segment_Tree{
        vector<int> a;
        int l, r;
 
        private:
        int __summ(int L, int R, int l, int r, int v)
        {
            if (L <= l && r <= R)
                return a[v];
            if (R <= l || r <= L)
                return 0;
            int m = (l + r) / 2;
            return __summ(L, R, l, m, 2 * v + 1) + __summ(L, R, m, r, 2 * v + 2);
        }
 
        void __set(int P, int l, int r, int v, int V)
        {
            if (l + 1 == r)
            {
                a[v] = V;
                return;
            }
            int m = (l + r) / 2;
            if (P < m)
            {
                __set(P, l, m, 2 * v + 1, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
            else
            {
                __set(P, m, r, 2 * v + 2, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
        }
 
        public:
        int Summ(int L, int R)
        {
            if (R < L)
                return 0;
            return __summ(L, R + 1, l, r, 0);
        }
 
        void Set(int P, int V)
        {
            __set(P, l, r, 0, V);
        }
 
        Small_Segment_Tree(int _n)
        {
            a.resize(4 * _n);
            l = 0, r = _n;
        }
    };
    long long inq(long long x, long long q, long long MOD)
    {
        if (q == 0)
            return 1;
        long long l = inq(x, q / 2, MOD);
        if (q % 2)
            return l * l % MOD * x % MOD;
        return l * l % MOD;
    }
};
 
 
using namespace MySpace;
 
#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long
 
void YN(int val)
{
    if (val >= 1)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
}
#define y0 y1234
//const ll MOD = 998244353;
const ll MOD = 1e12 + 7;

ll x, y;
ll x0, y0;
ll k;
vector<pii> ans;

pair<int, int> Catch(int x1, int y1, int x2, int y2)
{
    int dx = abs(x2 - x1);
    int dy = abs(y2 - y1);
    if (dx > 2 * k || dy > 2 * k)
    {
        return {-MOD, -MOD};
    }
    int mx1 = x1 + y1;
    int my1 = x1 - y1;
    int mx2 = x2 + y2;
    int my2 = x2 - y2;
    int h[4] = {mx1 - k, mx1 + k, mx2 - k, mx2 + k};
    sort(h, h + 4);
    int w[4] = {my1 - k, my1 + k, my2 - k, my2 + k};
    sort(w, w + 4);
    int mX = h[1];
    int mY = w[1];
    int x = (mX + mY) / 2;
    int y = (mX - mY) / 2;
    return {x, y};
}

vector<char> ss;
vector<int> z;
vector<char> ms;
signed main()
{
    ios_base::sync_with_stdio();
    cin.tie(0);
    cout.tie(0);
    S s, t;
    cin >> s >> t;
    
    while (ms.size() <= t.size())
    {
        for (int i = 0; i < s.size(); i++)
        {
            ms.push_back(s[i]);
        }
    }
    //for (int i = 0; i < ms.size(); i++) cout << ms[i];
    //cout << endl;
    
    int kek = 3 * ms.size();
    while (kek >= 0)
    {
        for (int i = 0; i < t.size(); i++)
        {
            ss.push_back(t[i]);
            kek--;
        }
    }
    ss.push_back('#');
    
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < ms.size(); j++)
        {
            ss.push_back(ms[j]);
        }
    }
    int L = 0, R = 0;
    z.resize(ss.size());
    for (int i = 1; i < ss.size(); i++)
    {
        z[i] = max(0, min(z[i - L], R - i));
        while (i + z[i] < ss.size() && ss[i + z[i]] == ss[z[i]])
            z[i]++;
        if (i + z[i] > R)
        {
            R = i + z[i];
            L = i;
        }
    }
    long long ans = 0;
    kek = 0;
    int t1 = 0;
    for (int i = 0; i < ss.size(); i++)
    {
        if (ss[i] == '#')
        {
            t1 = 1;
        }
        if (t1 == 0)
        {
            kek++;
        }
        else
        {
            if (z[i] == kek)
            {
                cout << "-1";
                return 0;
            }
            ans = max(ans, z[i] / (int)t.size());
        }
    }
    cout << ans;
}


Measured memory_bytes: 68596