#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

// Roling Hash
// RollingHash RH(s,base) base:[2,MOD)の乱数
// RH.set(s,base): vectorを再構築するのは重いのでコンストラクタを使わない
// RH.get(l,r): [l,r)のハッシュ O(1)
// 1000000007, 1000000009, 1000000021
template <long long MOD> struct RollingHash {
	int n;
	long long base;
	vector<long long> pow, hash;
	RollingHash() {}
	RollingHash(const string &s, long long base_ = 10007) { init(s, base_); }
	void init(const string &s, long long base_ = 10007) {
		n = s.size();
		base = base_;
		calc(s.c_str());
	}
	long long get(int x) const { return hash[x]; }
	long long get(int l, int r) const {
		return (get(r) - get(l) * pow[r - l] % MOD + MOD) % MOD;
	}
	void calc(const char *s) {
		pow.resize(n + 1);
		pow[0] = 1;
		hash.resize(n + 1);
		hash[0] = 0;
		for (int i = 0; i < n; i++) {
			pow[i + 1] = pow[i] * base % MOD;
			hash[i + 1] = (s[i] + hash[i] * base) % MOD;
		}
	}
};

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string s; cin >> s;
	string t; cin >> t;


	string x = s;
	while (x.size() < t.size()) {
		x = x + x;
	}
	x = x + x;


	RollingHash<MOD>rhx(x), rht(t);

	vector<int>visited(s.size());
	vector<int>dp(s.size());
	int ans = 0;

	function<int(int)>dfs = [&](int cur) {
		if (visited[cur]==1)return dp[cur];
		if (visited[cur] == 2) {
			cout << -1 << endl;
			exit(0);
		}
		visited[cur] = 2;
		int nxt = (cur + t.size());
		int h1 = rhx.get(cur, nxt);
		int h2 = rht.get(0, t.size());
		if (h1 == h2) {
			dump(cur, "->", nxt%s.size());
			int ret=dfs(nxt%s.size());
			dp[cur] = ret + 1;
		}
		visited[cur] = 1;
		return dp[cur];
	};

	rep(i, 0, s.size()) {
		dump(i);
		dump(dp);
		dump(visited);
		chmax(ans, dfs(i));
	}
	cout << ans << endl;





	return 0;
}


Measured memory_bytes: 74824