using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		var t=sc.S;
		if(s.Length<t.Length){
			int p=t.Length/s.Length+(t.Length%s.Length==0?0:1);
			s=Fp(s,p);
		}
		var s2=s+s.Substring(0,t.Length-1);
		Uf uf=new Uf(s.Length);
		int ans=1;
		bool bo=false;
		s2.Rh(t,1009,mod,(i)=>{
			if(uf.Same(i,(i+t.Length)%s.Length)){bo=true;}
			uf.Union(i,(i+t.Length)%s.Length);
			ans=Max(ans,uf.Total(i));
		});
		Console.WriteLine("{0}",bo?-1:ans-1);
	}
	static string Fp(string s,long e){
		string r="";
		while(e>0){
			if((e&1)>0){r+=s;}
			s+=s;
			e>>=1;
		}
		return r;
	}
}
public class Uf{
	private int[] arr,hi;
	public int all;
	public Uf(int n){
		arr=new int[n];
		hi=new int[n];
		all=n;
		for(int i=0;i<n;i++){arr[i]=-1;}
	}
	public void Union(int a,int b){
		a=Root(a);
		b=Root(b);
		if(a!=b){
			if(hi[a]<hi[b]){
				int v=b;
				b=a;
				a=v;
			}
			arr[a]+=arr[b];
			hi[a]=Math.Max(hi[a],hi[b]+1);
			arr[b]=a;
			all--;
		}
	}
	public bool Same(int a,int b){return Root(a)==Root(b);}
	public int Total(int a){return -arr[Root(a)];}
	public int Root(int a){return arr[a]<0?a:arr[a]=Root(arr[a]);}
}
static class Ex2{
	public static void Rh(this string a,string s,int b,int mod,Action<int> f){
		int n=a.Length,m=s.Length;
		long r=Hs(a,b,mod,m),h=Hs(s,b,mod),c=Fp(b,m,mod);
		if(r==h){f(0);}
		for(int i=m;i<n;i++){
			r=(r*b+(a[i]-47))%mod;
			r=(mod+r-(((a[i-m]-47)*c)%mod))%mod;
			if(r==h){f(i-m+1);}
		}
	}
	public static long Hs(string s,int a,int mod){
		int n=s.Length;
		long p=0;
		for(int i = 0;i<n;i++) {p=(p+(s[i]-47)*Fp(a,n-1-i,mod))%mod;}
		return p;
	}
	public static long Hs(string s,int a,int mod,int n){
		long p=0;
		for(int i = 0;i<n;i++) {p=(p+(s[i]-47)*Fp(a,n-1-i,mod))%mod;}
		return p;
	}
	private static long Fp(long x,long e,int mod){
		long r=1;
		while(e>0){
			if((e&1)>0){r*=x;r%=mod;}
			x=(x*x)%mod;
			e>>=1;
		}
		return r;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 25824