#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

std::vector<int> ZAlgorithm(const std::string& s)
{
    std::vector<int> z(s.size());
    z[0] = s.size();

    int index = 1;
    int matched = 0;
    while (index < s.size())
    {
        while (index + matched < s.size() && s[matched] == s[index + matched])
            matched++;

        z[index] = matched;
        if (matched == 0)
        {
            index++;
            continue;
        }

        int copyLength = 1;
        while (copyLength < matched && copyLength + z[copyLength] < matched)
        {
            z[index + copyLength] = z[copyLength];
            copyLength++;
        }
        index += copyLength;
        matched -= copyLength;
    }

    return z;
}

std::vector<int> GetCorrespondLengthArray(const std::string& s, const std::string& t)
{
    std::vector<int> cor(s.size());
    auto z = ZAlgorithm(t + s);
    for (auto i = 0; i < s.size(); i++)
        cor[i] = std::min(z[i + t.size()], (int)t.size());

    return cor;
}

enum VisitStatus
{
    NotVisited,
    VisitedInLoop,
    Visited,
};

bool DFS(const std::vector<std::vector<int>> &connection,
        int current,
        std::vector<VisitStatus>& visitTable,
        std::vector<int>& distanceTable)
{
    visitTable[current] = VisitedInLoop;
    auto dist = 0;

    for (auto& c : connection[current])
    {
        if (visitTable[c] == NotVisited)
        {
            auto cycle = DFS(connection, c, visitTable, distanceTable);
            if (cycle)
                return true;
        }
        else if (visitTable[c] == VisitedInLoop)
        {
            return true;
        }

        dist = std::max(dist, distanceTable[c] + 1);
    }

    visitTable[current] = Visited;
    distanceTable[current] = dist;
    return false;
}

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

    std::string S, T, str;
    std::cin >> S >> T;

    auto length = std::max(T.size(), S.size()) * 2;
    while (str.size() < length)
        str += S;

    auto cor = GetCorrespondLengthArray(str, T);

    std::vector<std::vector<int>> connection(S.size());
    for (auto i=0; i<S.size(); i++)
    {
        // i文字目から i+t−1 文字目までの部分文字列が t と一致する
        //  -> tmp の部分文字列となるように t を連続で繋げる数を最大化
        //  -> t が連続で繋がる = i + t.size() に接続されるノードがある
        if (T.size() <= cor[i])
            connection[i].emplace_back((i + T.size()) % S.size());
    }

    std::vector<VisitStatus> visitTable(S.size(), NotVisited);
    std::vector<int> distanceTable(S.size(), -1);
    auto cycle = false;
    for (auto i=0; i<S.size(); i++)
    {
        if (distanceTable[i] == -1)
            cycle = DFS(connection, i, visitTable, distanceTable);

        if (cycle)
        {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    auto result = 0;
    for (auto i=0; i<S.size(); i++)
        result = std::max(result, distanceTable[i]);

    std::cout << result << std::endl;
}

Measured memory_bytes: 81708