#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

typedef unsigned long long HASH;

class RollingHash {
public:
	static const ULL HMOD = (1ULL << 61) - 1;
	static const ULL MASK30 = (1ULL << 30) - 1;
	static const ULL MASK31 = (1ULL << 31) - 1;
	static ULL base;
	static const ULL POS = HMOD * ((1ULL << 3) - 1);
	static vector<ULL> powmemo;
	vector<HASH> hash;   //部分列[0,n)のハッシュを持つ
	//文字列S,time回繰り返し
	RollingHash(vector<LL>& S,LL time = 1) {
		LL N = S.size();
		if (base == 0) {
			random_device rnd;
			mt19937 mt(rnd());
			uniform_int_distribution<ULL> rand(129, HMOD - 1);
			RollingHash::base = rand(mt);
			powmemo.resize(500000, 1);
			for (LL n = 1; n < 500000; n++) {
				powmemo[n] = mod(Mul(powmemo[n - 1], base));
			}
		}
		hash.resize(N*time);
		hash[0] = S[0];
		for (LL t = 0; t < time; t++) {
			for (LL n = 0; n < N; n++) {
				if (t == 0 && n == 0)continue;
				hash[t*N+n] = mod(Mul(hash[t*N+n - 1], base) + S[n]);
			}
		}
	}
	//部分列[a,b)のハッシュ
	HASH get(LL a, LL b) {
		HASH ans = hash[b - 1];
		if (a - 1 >= 0) {
			ans = mod(ans + POS - Mul(hash[a - 1], powmemo[b - a]));
		}
		return ans;
	}
	//部分列配列への保存なしに変換
	HASH conv(vector<LL>& S) {
		HASH ans = 0;
		for (LL n = 0; n < S.size(); n++) {
			ans = mod(Mul(ans, base) + S[n]);
		}
		return ans;
	}
	static HASH Mul(HASH a, HASH b) {
		HASH au = a >> 31;
		HASH ad = a & MASK31;
		HASH bu = b >> 31;
		HASH bd = b & MASK31;
		HASH midd = au * bd + ad * bu;
		HASH midu = midd >> 30;
		midd = midd & MASK30;
		return ((au * bu) << 1) + ad * bd + (midd << 31) + midu;
	}
	static HASH mod(HASH val) {
		val = (val & HMOD) + (val >> 61);
		if (val >= HMOD)val -= HMOD;
		return val;
	}
};
ULL RollingHash::base = 0;
vector<ULL> RollingHash::powmemo = vector<ULL>();

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S, T;
	cin >> S >> T;
	VLL vs(S.size()), vt(T.size());
	LL sl = S.size();
	LL tl = T.size();
	for (LL n = 0; n < sl; n++) {
		vs[n] = S[n] - 'a'+1;
	}
	for (LL n = 0; n < tl; n++) {
		vt[n] = T[n] - 'a'+1;
	}
	LL stime = 1;
	while (sl * (stime+1) <= 5e5) {
		stime++;
	}
	RollingHash rs(vs,stime);
	RollingHash rt(vt);
	vector<bool> check(sl, true);
	for (LL k = 0; k < sl; k++) {
		LL tpos = 0;
		LL ss = k;
		while (check[k]) {
			if (tl - tpos + ss > sl*stime) {
				check[k] = check[k] & (
					rs.get(ss, sl*stime) == rt.get(tpos, tpos + sl*stime - ss)
					);
				tpos = tpos + sl*stime - ss;
				ss = 0;
			}
			else {
				check[k] = check[k] & (
					rs.get(ss, tl - tpos + ss) == rt.get(tpos, tl)
					);
				break;
			}
		}
	}
	VVLL doubling;
	doubling.resize(sl, VLL(20,-1));
	for (LL n = 0; n < sl; n++) {
		if (check[n]) {
			LL next = n + tl;
			next %= sl;
			doubling[n][0] = next;
		}
	}
	for (LL t = 1; t < 20; t++) {
		for (LL n = 0; n < sl; n++) {
			if (doubling[n][t - 1] != -1) {
				LL next = doubling[n][t - 1];
				if (next == -1)continue;
				next = doubling[next][t - 1];
				doubling[n][t] = next;
			}
		}
	}
	LL ans = 0;
	for (LL n = 0; n < sl; n++) {
		//sまで!=-1,eから-1
		LL s = -1, e = 5e5 + 2;
		while (e - s > 1) {
			LL m = (e + s) / 2;
			LL next = n;
			for (LL t = 0; t < 20; t++) {
				if (((LL)1 << t) & m)next = doubling[next][t];
				if (next == -1)break;
			}
			if (next == -1)e = m;
			else s = m;
		}
		ans = max(ans, s);
	}
	if (ans == 5e5+1) {
		cout << -1 << "\n";
	}
	else {
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 118556