#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

ll dp[N][13];

template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;

main(){
    string ss,t;
    cin>>ss>>t;
    string s;
    while(s.size()<t.size()){
        s+=ss;
    }
    s=s+s;
    string p=s;
    s=s+s;
    RH rh(s);
    int l=0,r=s.size()/t.size()+1;
    while(l<r-1){
        int mid=(l+r)/2;
        string T;
        rep(i,mid)T+=t;
        RH rr(T);
        ll A=rr.get(0,T.size());
        bool flag=0;
        rep(i,s.size()-T.size()){
            if(rh.get(i,i+T.size())==A){
                flag=1;
            }
        }
        if(flag)l=mid;
        else r=mid;
    }
    int ans=l;
    s=s+p;
    RH rh3(s);
    l=ans,r=s.size()/t.size()+1;
    string tt;
    rep(i,ans)tt+=t;
    while(l<r-1){
        int mid=(l+r)/2;
        string T=tt;
        rep(i,mid-ans)T+=t;
        RH rr(T);
        ll A=rr.get(0,T.size());
        bool flag=0;
        rep(i,s.size()-T.size()){
            if(rh3.get(i,i+T.size())==A){
                flag=1;
            }
        }
        if(flag)l=mid;
        else r=mid;
    }
    int ans2=l;
    if(ans<ans2){
        cout<<-1;
    }
    else cout<<ans;
}



Measured memory_bytes: 149888