#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}

ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}


int Hash[5000010], hash_t;
int b = 1e7 + 1, h = 1e9 + 7;
string S, T;
bool used[5000010];
int get_hash(string S) {
	int N = S.size();
	int res = 0;
	REP(i, N) {
		res = mult(res, b);
		res += S[i] - 'a' + 1;
	}
	//res = mult(res, b);
	return res % MOD;
}

int calc(string S, string T) {
	int N = S.size();
	int M = T.size();
	while (S.size() < 4*1e6)S += S;
	int fir = 0;
	REP(i, M) {
		fir = mult(fir, b);
		fir += S[i] - 'a' + 1;
	}
	Hash[0] = fir;
	//print(Hash[0]);
	REP(i, 4*1e6 - M) {
		int res = Hash[i];
		res = mult(res, b);
		res = sub(res, mult(S[i] - 'a' + 1, bin_pow(b, M)));
		res = add(res, S[i + M] - 'a' + 1);
		Hash[i + 1] = res;
		//if(i<20)print(Hash[i + 1]);
	}
	int mx = 0;
	REP(i, 4*1e6 - M) {
		//if (i > 1000)break;
		if (used[i])continue;
		used[i] = true;
		int cnt = 0;
		if (Hash[i] == hash_t) {
			cnt++;
			//pe(i); print(cnt);
			int nex = i + M;
			used[nex] = true;
			while (nex < 4 * 1e6 - M &&Hash[nex] == hash_t) {
				cnt++;
				//pe(nex)print(cnt);
				nex += M;
				used[nex] = true;
				if (cnt >(3*1e6) / M)return -1;
			}
		}
		chmax(mx, cnt);
	}
	return mx;
}

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

	cin >> S >> T;
	hash_t = get_hash(T);
	//print(hash_t);
	print(calc(S, T));
}


Measured memory_bytes: 47512