#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////


struct RandomNumberGenerator {
    mt19937 mt;

    RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

    unsigned long long operator()(unsigned long long a, unsigned long long b) { // [a, b)
        uniform_int_distribution<unsigned long long> dist(a, b - 1);
        return dist(mt);
    }

    unsigned long long operator()(unsigned long long b) { // [0, b)
        return (*this)(0, b);
    }
};

RandomNumberGenerator RNG;
const unsigned long long base1 = RNG(1ull<<30,1ull<<31);
const unsigned long long base2 = RNG(1ull<<30,1ull<<31);

template <typename S>
struct RollingHash {

    const ull MASK30 = (1ull << 30) - 1;
    const ull MASK31 = (1ull << 31) - 1;
    const ull mod = (1ull << 61) - 1;
    const ull POSITIVIZER = mod * ((1ull << 3) - 1);

    vector<ull> hash1,hash2,power1,power2;

    RollingHash(const S &s) {
        int sz = s.size();
        hash1.assign(sz + 1,0);
        hash2.assign(sz + 1,0);
        power1.assign(sz + 1,1);
        power2.assign(sz + 1,1);
        for (int i = 0; i < sz; i++) {
            power1[i+1] = CalcMod(Mul(power1[i],base1));
            hash1[i+1] = CalcMod(Mul(hash1[i],base1) + s[i] + 1);
            power2[i+1] = CalcMod(Mul(power2[i],base2));
            hash2[i+1] = CalcMod(Mul(hash2[i],base2) + s[i] + 1);
        }
    }

    pair<ull,ull> get(int l, int r) { // [l,r) (0-indexed)
        pair<ull,ull> ret;
        ret.first = CalcMod(hash1[r] + POSITIVIZER - Mul(hash1[l],power1[r-l]));
        ret.second = CalcMod(hash2[r] + POSITIVIZER - Mul(hash2[l],power2[r-l]));
        return ret;
    }

	int LCP(RollingHash &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);
	}

    ull Mul (ull a, ull b) {
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        ull midu = mid >> 30;
        ull midd = mid & MASK30;
        return (au * bu * 2 + midu + (midd << 31) + ad * bd);
    }

    ull CalcMod(ull val) {
        val = (val & mod) + (val >> 61);
        if (val >= mod) val -= mod;
        return val;
    }
};

using puu = pair<ull, ull>;
const int MAX = 505050;
int G[MAX];
int dp[MAX];

int dfs(int v) {
    dp[v] = -2;
    if (G[v]==-1) return dp[v] = 0;
    if (dp[G[v]]==-2) return dp[v] = 1e9;
    if (dp[G[v]] >= 0) return dp[v] = dp[G[v]]+1;
    return dp[v] = dfs(G[v])+1;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S,T; cin >> S >> T;
    int N = S.size();
    int M = T.size();

    string SS = "";
    rep(i,(M+N-1)/N*2) SS += S;
    RollingHash<string> RH1(SS),RH2(T);
    rep(i,N) dp[i] = -1;
    rep(i,N) G[i] = -1;
    rep(i,N) {
        if (RH1.get(i,i+M)==RH2.get(0,M)) {
            G[i] = (i+M)%N;
        }
    }
    rep(i,N) {
        if (dp[i] >= 0) continue;
        dfs(i);
    }
    int ans = 0;
    rep(i,N) chmax(ans,dp[i]);
    cout << (ans >= 1e9 ? -1 : ans) << ln;
}

Measured memory_bytes: 93512