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);}


function main(){
  var s = o.a(1);
  var t = o.a(1);
  var s2 = "";
  var sl = s.length;
  var tl = t.length;
  for(var i = 0; i <= tl*2 || i < sl*2; i += sl){
    s2 += s;
  }
  var s3 = s2;
  for(;i <= tl*3 || i < sl*3; i += sl){
    s3 += s;
  }
  var t1 = t, ans = 0;
  while(1){
    if(s2.match(t1)){
      t1 += t;
      ans++;
    }else break;
  }
  if(s3.match(t1))return -1;
  return ans;
}
if (process.argv.length <= 2) require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=240000"] });
else {
  console.log(main());
}