#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
template<unsigned int modulo = 1000000007>
class modInt {
	ll value;
public:
	modInt() : value(0) {}
	template<typename T>
	modInt(T value = 0) : value(value) {
		if (value < 0)value = -(ll)(-value % modulo) + modulo;
		this->value = value % modulo;
	}
	inline operator int()const { return value; }
	inline modInt& operator+=(const modInt& x) {
		value += x.value;
		if (value >= modulo)value -= modulo;
		return *this;
	}
	inline modInt& operator++() {
		if (value == modulo - 1)value = 0;
		else value++;
		return *this;
	}
	inline modInt operator-()const {
		return modInt(0) -= *this;
	}
	inline modInt& operator-=(const modInt& x) {
		value -= x.value;
		if (value < 0)value += modulo;
		return *this;
	}
	inline modInt& operator--() {
		if (value == 0)value = modulo - 1;
		else value--;
		return *this;
	}
	inline modInt& operator*=(const modInt& x) {
		value = value * x.value % modulo;
		return *this;
	}
	inline modInt& operator/=(modInt rhs) {
		int exp = modulo - 2;
		while (exp) {
			if (exp & 1)*this *= rhs;
			rhs *= rhs;
			exp >>= 1;
		}
		return *this;
	}
	template<typename T> modInt operator+(const T& rhs)const { return modInt(*this) += rhs; }
	template<typename T> modInt& operator+=(const T& rhs) { return operator+=(modInt(rhs)); }
	template<typename T> modInt operator-(const T& rhs)const { return modInt(*this) -= rhs; }
	template<typename T> modInt& operator-=(const T& rhs) { return operator-=(modInt(rhs)); }
	template<typename T> modInt operator*(const T& rhs)const { return modInt(*this) *= rhs; }
	template<typename T> modInt& operator*=(const T& rhs) { return operator*=(modInt(rhs)); }
	template<typename T> modInt operator/(const T& rhs)const { return modInt(*this) /= rhs; }
	template<typename T> modInt& operator/=(const T& rhs) { return operator/=(modInt(rhs)); }
};
class RollingHash {
	string s;
	int n;
	modInt<> base;
	vector<modInt<>> has, power;
public:
	RollingHash(string s, ll b) : n(s.size()), base(b) { init(s, b); }
	void init(string s, ll b) {
		n = s.size();
		has.resize(n);
		power.resize(n);
		base = modInt<>(b);
		this->s = s;
		rep(i, n) {
			has[i] = modInt<>(s[i]);
			if (i) {
				has[i] += base * has[i - 1];
				power[i] = power[i - 1] * base;
			}
			else power[i] = 1;
		}
	}
	operator int() const {
		return has.back();
	}
	ll query(ll a, ll b) {
		assert(!(a >= b || a < 0 || n < b));
		return has[b - 1] - power[b - a] * (!a ? modInt<>(0) : has[a - 1]);
	}
	RollingHash& operator+=(string t) {
		s += t;
		has.resize(n + t.size());
		power.resize(n + t.size());
		for (int i = n; i < n + t.size(); i++) {
			has[i] = modInt<>(t[i] * base);
			has[i] += base * has[i - 1];
			power[i] = power[i - 1] * base;
		}
		n += t.size();
		return *this;
	}
};
string s, t;
int edge[500010], dist[500010];
bool used[500010], in[500010];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> s >> t;
	int n = s.size();
	string ns;
	while (ns.size() < t.size() * 2)ns += s;
	s = ns;
	s += s;
	fill(edge, edge + n, -1);
	RollingHash rhs1(s, 1007), rhs2(s, 10007), rht1(t, 1007), rht2(t, 10007);
	bool f = false;
	rep(i, n) {
		if (rhs1.query(i, i + t.size()) == rht1 && rhs2.query(i, i + t.size()) == rht2) {
			edge[i] = (i + t.size()) % n;
			in[(i + t.size()) % n] = true;
			f = true;
		}
	}
	if (!f) {
		cout << 0 << endl;
		return 0;
	}
	queue<int> que;
	int ans = -1;
	rep(i, n) {
		if (!used[i] && !in[i]) {
			que.push(i);
			dist[i] = 0;
			used[i] = true;
			while (!que.empty()) {
				int node = que.front();
				que.pop();
				if (dist[node])ans = max(ans, dist[node]);
				if (edge[node] != -1) {
					if (used[edge[node]]) {
						cout << -1 << endl;
						return 0;
					}
					dist[edge[node]] = dist[node] + 1;
					used[node] = true;
					que.push(edge[node]);
				}
			}
		}
	}
	if (!ans)cout << -1 << "\n";
	else cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 131752