#include "bits/stdc++.h"

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

struct characters {
	// lower alphabets
	static int const size = 26;
	static int convert(char c) {
		// assert('a' <= c && c <= 'z');
		return c - 'a';
	}
	static char invert(int i) {
		// assert(0 <= i && i < size);
		return 'a' + i;
	}
};

template <typename Characters> class AhoCorasick {
	static constexpr int invalidIndex = -1;

	struct PMA {
		int fail;
		std::vector<int> next, accept;

		PMA() : fail(invalidIndex), next(Characters::size, invalidIndex) {}
	};

	const int K;
	std::vector<std::unique_ptr<PMA>> nodes;

	int transition(int nodeIndex, char cc) {
		// assert(0 <= nodeIndex && nodeIndex < (int)nodes.size());
		int c = Characters::convert(cc);
		int now = nodeIndex;
		while (nodes[now]->next[c] == invalidIndex && now != 0) {
			now = nodes[now]->fail;
		}
		now = nodes[now]->next[c];
		if (now == invalidIndex) now = 0;
		return now;
	}

  public:
	AhoCorasick(const std::vector<std::string> &ts) : K((int)ts.size()) {
		const int rootIndex = 0;
		// root node
		nodes.push_back(std::make_unique<PMA>());
		nodes[rootIndex]->fail = rootIndex;
		for (int i = 0; i < K; i++) {
			int now = rootIndex;
			for (auto cs : ts[i]) {
				int c = Characters::convert(cs);
				if (nodes[now]->next[c] == invalidIndex) {
					nodes[now]->next[c] = (int)nodes.size();
					nodes.push_back(std::make_unique<PMA>());
				}
				now = nodes[now]->next[c];
			}
			nodes[now]->accept.push_back(i);
		}

		std::queue<int> que;
		for (int c = 0; c < Characters::size; c++) {
			if (nodes[rootIndex]->next[c] != invalidIndex) {
				nodes[nodes[rootIndex]->next[c]]->fail = rootIndex;
				que.push(nodes[rootIndex]->next[c]);
			}
		}
		while (!que.empty()) {
			int now = que.front();
			que.pop();
			for (int c = 0; c < Characters::size; c++) {
				if (nodes[now]->next[c] != invalidIndex) {
					que.push(nodes[now]->next[c]);
					int nxt =
					    transition(nodes[now]->fail, Characters::invert(c));
					nodes[nodes[now]->next[c]]->fail = nxt;
					for (auto ac : nodes[nxt]->accept) {
						nodes[nodes[now]->next[c]]->accept.push_back(ac);
					}
				}
			}
		}
	}
	std::vector<std::vector<int>> match(const std::string &str) {
		std::vector<std::vector<int>> ret(K);
		int now = 0;
		for (int i = 0; i < (int)str.size(); i++) {
			now = transition(now, str[i]);
			for (auto k : nodes[now]->accept) {
				ret[k].push_back(i);
			}
		}
		return ret;
	}
};

struct UnionFind {
	std::vector<int> par;
	std::vector<int> sizes;

	UnionFind(int n) {
		par.resize(n);
		sizes.resize(n);
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			sizes[i] = 1;
		}
	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (sizes[x] < sizes[y]) std::swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}
	int size(int x) {
		return sizes[root(x)];
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string ss, t;
	cin >> ss >> t;

	vector<string> init = {t};
	string s;
	while (s.size() < t.size())
		s += ss;
	AhoCorasick<characters> aho(init);
	set<int> pos;
	{
		string tmp = s + s;
		vvi res = aho.match(tmp);
		REP(i, res[0].size()) pos.insert(res[0][i] - t.size() + 1);
	}
	int n = s.size();
	UnionFind uf(n);
	for (auto a : pos) {
		if (a >= n) break;
		if (uf.same(a, (a + t.size()) % n)) {
			cout << -1 << endl;
			return 0;
		}
		uf.unite(a, (a + t.size()) % n);
	}
	map<int, int> mp;
	REP(i, n) mp[uf.root(i)]++;
	int ans = 0;
	for (auto a : mp) {
		chmax(ans, a.second - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 172208