var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var UnionFind = (function(){
  var a;
  function f(n){return new UnionFind(n);}
  function UnionFind(n){
    a = this.a = Array(n+1).fill(-1);
  }
  UnionFind.prototype.root = function(i){
    if(a[i] < 0)return i;
    return a[i] = this.root(a[i]);
  };
  UnionFind.prototype.same = function(x,y){
    return this.root(x) === this.root(y);
  };
  UnionFind.prototype.unite = function(x,y){
    x = this.root(x), y = this.root(y);
    if(x === y)return false;
    if(x < y)a[x] += a[y], a[y] = x;
    else a[y] += a[x], a[x] = y;
    return true;
  };
  UnionFind.prototype.size = function(i){
    return -a[this.root(i)];
  }
  return f;
})();

function Z_Algorithm(s){
  var l=s.length,a=Array(l);
  a[0]=l;
  for(var i=1,j=0;i<l;){
    while(i+j<l && s[j]===s[i+j])++j;
    a[i]=j;
    if(j === 0){++i; continue;}
    var k=1;
    while(i+k<l && k+a[k]<j)a[i+k]=a[k], ++k;
    i += k; j -= k;
  }
  return a;
}

console.log(main());
function main(){
  var s = o.a(1);
  var t = o.a(1);
  var sl=s.length;
  var tl=t.length;
  var ss=s+s;
  while(ss.length<sl+tl)ss+=s;
  var uf=UnionFind(sl);
  var za=Z_Algorithm(t+ss);
  for(var i=0;i<sl;i++){
    if(za[i+tl]>=tl){
      if(!uf.unite(i,(i+tl)%sl))return -1;
    }
  }
  var ans=1;
  for(i=0;i<sl;i++){
    var t=uf.size(i);
    if(ans<t)ans=t;
  }
  return ans-1;
}