#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
template<unsigned mod>
struct RollingHash {
    vector<unsigned> hashed, power;

    inline unsigned mul(unsigned a, unsigned b) const {
        unsigned long long x = (unsigned long long) a * b;
        unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
        asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
        return m;
    }

    RollingHash(const string &s, unsigned base = 10007) {
        int sz = (int) s.size();
        hashed.assign(sz + 1, 0);
        power.assign(sz + 1, 0);
        power[0] = 1;
        for (int i = 0; i < sz; i++) {
            power[i + 1] = mul(power[i], base);
            hashed[i + 1] = mul(hashed[i], base) + s[i];
            if (hashed[i + 1] >= mod) hashed[i + 1] -= mod;
        }
    }

    unsigned get(int l, int r) const {
        unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
        if (ret >= mod) ret -= mod;
        return ret;
    }

    unsigned connect(unsigned h1, int h2, int h2len) const {
        unsigned ret = mul(h1, power[h2len]) + h2;
        if (ret >= mod) ret -= mod;
        return ret;
    }

    int LCP(const RollingHash<mod> &b, int l1, int r1, int l2, int r2) {
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
            else high = mid;
        }
        return (low);
    }
};

using RH7 = RollingHash<1000000007>;
using RH9 = RollingHash<998244353>;

class Solve {
public:
    void solve() {
        string s, t;
        cin >> s >> t;

        string S;
        while (S.size() < s.size() + t.size()) {
            S += s;
        }

        pair<RH7, RH9> rhs = make_pair(RH7(S), RH9(S)), rht = make_pair(RH7(t), RH9(t));

        vector<vector<Int>> G(s.size());
        vector<Int> dp(s.size(), -1);

        for (int i = 0; i < s.size(); ++i) {
            pair<Int, Int> x = make_pair(rhs.first.get(i, i + t.size()), rhs.second.get(i, i + t.size()));
            pair<Int, Int> y = make_pair(rht.first.get(0, t.size()), rht.second.get(0, t.size()));

            if (x == y) {
                G[i].push_back((i + t.size()) % s.size());
            }
        }

        vector<int> vis(s.size()); // 0 mada, 1 visiting, 2 visited
        auto dfs = [&](auto self, int v) -> Int {
            if (dp[v] != -1) return dp[v];
            if (G[v].size() == 0) {
                return dp[v] = 0;
            }
            if (vis[v] == 1) {
                return INF;
            }

            Int ret = 0;
            vis[v] = 1;
            for (auto e : G[v]) {
                Int tmp = self(self, e);
                if (tmp != INF) tmp++;
                chmax(ret, tmp);
            }

            vis[v] = 2;
            return dp[v] = ret;
        };

        for (int i = 0; i < G.size(); ++i) {
            dfs(dfs, i);
        }

        Int ans = 0;
        for (int i = 0; i < s.size(); ++i) {
            chmax(ans, dp[i]);
        }
        if (ans == INF) ans = -1;
        cout << ans << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 106296