#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 500100

ll n,m;
string s,t;
ll pi[MAX];

vector<ll> prefix_function(string s) {
    ll n = (ll)s.length();
    vector<ll> pi(n);
    for (ll i = 1; i < n; i++) {
        ll j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}

vector<ll> adj[MAX];
ll visited[MAX];

bool is_cycle(ll start){
	if(visited[start]==1) return 1;
	visited[start] = 1;
	for(ll x:adj[start]) if(visited[x]!=2){
		if(is_cycle(x)) return 1;
	}
	visited[start] = 2;	
	return 0;
}

ll dp[MAX];

ll f(ll s){
	if(dp[s]!=-1) return dp[s];
	ll ans = 0;
	for(ll x:adj[s]){
		ll t = f(x)+1;
		ans = max(ans,t);
	}
	dp[s] = ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>s>>t;
	n = s.size() , m = t.size();

	string S = s;

	while(S.size()<max(m,n)*10){
		for(char c:s) S.pb(c);
	}

	vector<ll> temp = prefix_function(t+"#"+S);
	ll count = 0;
	For(i,t.size()+m,temp.size()) {
		if(count>=n) break;

		ll index = (i-(m-1+(m+1))+(m+10)*n)%n;
		if(temp[i]==m) pi[index]=1;
		else pi[index]=0;
		count++;

		// trace(index);

		if(pi[index]){
			adj[index].pb((index+m)%n);
		}
	}
	memset(visited,0,sizeof(visited));

	For(i,0,n) if(visited[i]==0){
		if(is_cycle(i)){
			cout<<-1<<endl;
			return 0;
		}
	}
	memset(dp,-1,sizeof(dp));

	ll ans = 0;
	For(i,0,n){
		ans = max(ans,f(i));
	}
	cout<<ans<<endl;























	
}

Measured memory_bytes: 107144