#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
string c1,c2;
char x1[5000005],x2[5000005];
int fail[5000005];
int cou[5000005];
int main(){
	cin>>c1>>c2;
	string t1=c1;
	while(c1.size()<=(int)(t1.size()+c2.size())*2) c1+=t1;
	c1+=t1;
	int f=0;
	int n1=c1.size();
	int n2=c2.size();
	fail[0]=-1;
	for (int i=1,j=-1;i<=n2; fail[i++] = ++j)
		while (j>=0&&c2[j]!=c2[i-1]) j=fail[j];
	for (int i=0,j=0;i<n1;++i) {
		while(j>=0&&c2[j]!=c1[i]) j = fail[j];
		if(++j==n2) cou[i]=1;
	}
	for(int i=n2;i<n1;i++) if(cou[i])cou[i]+=cou[i-n2];
	int ma=0;
	for(int i=0;i<n1;i++){
		ma=max(ma,cou[i]);
	}
	if(ma>=n1/n2-2) cout<<-1;
	else cout<<ma;
}