// F - Strings of Eternity
#include <bits/stdc++.h>

using namespace std;

vector<int> z_func(const string &p)
{
	vector<int> z(p.size());
	for (int l = 0, r = 0, i = 1, n = p.size(); i < n; i++)
		if (r >= i && z[i - l] < r - i + 1) {
			z[i] = z[i - l];
		} else {
			if (i > r) r = i;
			for (l = i; r < n && p[r - l] == p[r]; ) r++;
			z[i] = r - l;
			r--;
		}
	return z;
}

int find(const string &s, const string &t)
{
	int m = t.size();
	string r = t + "|" + s;
	vector<int> z = z_func(r);
	vector<int> dp(z.size() + 1);
	for (int i = m; i < z.size(); i++)
		if (z[i] == m) dp[i + m] = max(dp[i + m], dp[i] + 1);
	return *max_element(dp.begin(), dp.end());
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	string s, t;
	cin >> s >> t;
	string r = s;
	while (r.size() <= s.size() + t.size() * 2) r += s;

	int ans = find(r, t);
	if (ans > 0 && find(r + r, t) != ans)
		ans = -1;

	cout << ans << endl;

	return 0;
}
