#include <cmath>
#include <iostream>
#include <string>
#include <vector>

std::vector<int> Z_construct(const std::string& S){
  int ns = S.size();
  std::vector<int> Z(ns);
  int L = 0, R = 0;
  for(int i = 0; i < ns; i++){
    if(i > R){
      L = R = i;
      while(R < ns && S[R-L] == S[R]) R++;
      Z[i] = R-L;
      R--;
    }else{
      int k = i-L;
      if(Z[k] < R-i+1){
        Z[i] = Z[k];
      }else{
        L = i;
        while(R < ns && S[R-L] == S[R]) R++;
        Z[i] = R-L;
        R--;
      }
    }
  }
  return Z;
}

std::vector<int> Z_alg(const std::string& S, const std::string& T){
  std::string C = T+"$"+S;
  auto Z = Z_construct(C);
  std::vector<int> ans(S.size());
  for(int i = 0; i < C.size(); i++){
    if(Z[i] == T.size()){
      ans[i-T.size()-1] = 1;
    }
  }
  return ans;
}

int main(){
  std::string S,T;
  std::cin >> S;
  std::cin >> T;

  int ns = S.size(), nt = T.size();
  std::string S2(S);
  while(S2.size() < ns+nt-1){
    S2 += S;
  }
  std::vector<int> f_arr = Z_alg(S2, T);
  std::vector<int> l_arr(ns);
  int ans = 0;
  for(int ni = 0; ni < ns; ni++){
    if(f_arr[((ni-nt)%ns+ns)%ns] == 1) continue;
    int n = ni, i = 0;
    while(true){
      l_arr[n] = 1;
      if(f_arr[n] == 0) break;
      n = (n+T.size())%S.size();
      i++;
    }
    ans = std::max(ans, i);
  }
  for(int i = 0; i < ns; i++){
    if(l_arr[i] == 0){
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  std::cout << ans << std::endl;

  return 0;
}

