#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

std::vector<int> z_algorithm(const std::string &s)
{
    int sz = s.length();
    std::vector<int> z(sz, 0);
    int i = 1, j = 0;
    while (i < sz)
    {
        while (i + j < sz && s[j] == s[i + j])
            j++;
        z[i] = j;
        if (j == 0)
        {
            i++;
            continue;
        }
        int k = 1;
        while (i + k < sz && k + z[k] < j)
        {
            z[i + k] = z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return z;
}

class Scc
{
    using Graph = std::vector<std::vector<int>>;
    int V, K;
    Graph G, rG;
    std::vector<int> vs;
    std::vector<bool> used;
    std::vector<int> cmp;
    void dfs(int cur)
    {
        used[cur] = true;
        for (const auto &v : G[cur])
        {
            if (!used[v])
                dfs(v);
        }
        vs.push_back(cur);
    }
    void rdfs(int cur, int k)
    {
        used[cur] = true;
        cmp[cur] = k;
        for (const auto &v : rG[cur])
        {
            if (!used[v])
                rdfs(v, k);
        }
    }

public:
    Scc(int _V) : V(_V), G(_V), rG(_V), used(_V, false), cmp(_V) {}
    void add_edge(int from, int to)
    {
        G[from].push_back(to);
        rG[to].push_back(from);
    }
    // SCCした後の頂点の対応関係(xor頂点数)を取得する
    int scc()
    {
        for (int i = 0; i < V; i++)
            used[i] = false;
        vs.clear();
        for (int v = 0; v < V; v++)
        {
            if (!used[v])
                dfs(v);
        }
        for (int i = 0; i < V; i++)
            used[i] = false;
        int k = 0;
        for (int i = (int)vs.size() - 1; i >= 0; i--)
        {
            if (!used[vs[i]])
                rdfs(vs[i], k++);
        }
        // 頂点数
        K = k;
        // cmp[i] := 頂点i がSCC後に属する強連結成分番号
        return K;
    }
    // 強連結成分を潰した後のグラフを得る
    Graph buildGraph()
    {
        scc();
        std::vector<std::set<int>> s(K);
        Graph ret(K);
        for (int v = 0; v < V; v++)
        {
            for (const auto to : G[v])
            {
                s[cmp[v]].insert(cmp[to]);
            }
        }
        for (int i = 0; i < K; i++)
        {
            for (auto j : s[i])
            {
                if (i != j)
                    ret[i].push_back(j);
            }
        }
        return ret;
    }
};

class TopologicalSort
{
    using Graph = std::vector<std::vector<int>>;
    // 頂点数
    int V;
    std::vector<std::vector<int>> G;
    void dfs(int v, std::vector<int> &res, std::vector<int> &used)
    {
        used[v] = 1;
        for (auto to : G[v])
            if (used[to] == 0)
            {
                dfs(to, res, used);
            }
        res.push_back(v);
    }

public:
    TopologicalSort(int _v) : V(_v), G(_v) {}
    void addEdge(int a, int b)
    {
        assert(0 <= a && a < V);
        assert(0 <= b && b < V);
        G[a].push_back(b);
    }
    std::vector<int> topologicalSort()
    {
        std::vector<int> ide(V);
        for (int i = 0; i < V; i++)
        {
            for (auto to : G[i])
            {
                ide[to]++;
            }
        }
        std::vector<int> res;
        std::vector<int> used(V);
        for (int i = V - 1; i >= 0; i--)
        {
            if (ide[i] == 0)
            {
                dfs(i, res, used);
            }
        }
        if (res.size() == 0)
            res = {-1};
        reverse(res.begin(), res.end());
        return res;
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;
    string u = s;
    int n = s.size(), m = t.size();
    while ((int)u.size() < n + m)
    {
        u += s;
    }
    vector<vector<int>> g(n);
    Scc scc(n);
    string w = t + "$" + u;
    auto z = z_algorithm(w);
    TopologicalSort ts(n);
    for (int i = 0; i < n; i++)
    {
        int index = m + 1 + i;
        if (z[index] >= m)
        {
            if (i == (i + m) % n)
            {
                cout << -1 << endl;
                return 0;
            }
            g[i].push_back((i + m) % n);
            ts.addEdge(i, (i + m) % n);
            scc.add_edge(i, (i + m) % n);
        }
    }
    if (scc.scc() != n)
    {
        cout << -1 << endl;
        return 0;
    }
    auto topo = ts.topologicalSort();
    if (topo.size() != n)
    {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ret(n, 0);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (auto v : g[topo[i]])
        {
            ret[v] = max(ret[v], ret[topo[i]] + 1);
            ans = max(ans, ret[v]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 139156