#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

struct HashTuple {
  static const vector<long long> Mod;
  static const int base;
  vector<long long> val;
  HashTuple(): val(Mod.size()) {}
  HashTuple(signed x): val(Mod.size(), x) {}
  HashTuple &operator+=(HashTuple that) {
    for(int i = 0; i < Mod.size(); i++) if ((val[i] += that.val[i]) >= Mod[i]) val[i] -= Mod[i];
    return *this;
  }
  HashTuple &operator-=(HashTuple that) {
    for(int i = 0; i < Mod.size(); i++) if ((val[i] += Mod[i] - that.val[i]) >= Mod[i]) val[i] -= Mod[i];
    return *this;
  }
  HashTuple operator+(HashTuple that) const { return HashTuple(*this) += that; }
  HashTuple operator-(HashTuple that) const { return HashTuple(*this) -= that; }
  HashTuple &operator*=(signed that) {
    for(int i = 0; i < Mod.size(); i++)
      val[i] = (unsigned long long)val[i] * that % Mod[i];
    return *this;
  }
  HashTuple operator*(signed that) const { return HashTuple(*this) *= that; }
  HashTuple &operator*=(HashTuple that) {
    for(int i = 0; i < Mod.size(); i++)
      val[i] = (unsigned long long)val[i] * that.val[i] % Mod[i];
    return *this;
  }
  HashTuple operator*(HashTuple that) const { return HashTuple(*this) *= that; }
  bool operator==(HashTuple that) const { return val == that.val; }
  bool operator!=(HashTuple that) const { return val != that.val; }
};
const vector<long long> HashTuple::Mod = {999999937LL, 1000000007LL};
const int HashTuple::base = 9973;

template<typename Hash>
struct RollingHash {
  int N, tuple_size = Hash::Mod.size();
  static vector<Hash> pw;
  vector<Hash> hs;
  RollingHash(){}
  RollingHash(const string &s)
  : N(s.size()), hs(N+1) {
    assert(N <= pw.size());
    for (int j = 0; j < N; j++) {
      hs[j+1] = hs[j] * Hash::base + s[j];
    }
  }
  static void init(int MAX_N){
    pw.resize(MAX_N+1);
    pw[0] = Hash(1);
    for(int j = 0; j < MAX_N; j++)
      pw[j+1] = pw[j] * Hash::base;
  }
  Hash hash(int l, int r) {
    // i-th hash[l,r)
    assert(0 <= l && l <= r && r <= N);
    return hs[r] - hs[l] * pw[r-l];
  }
};
template<typename Hash> vector<Hash> RollingHash<Hash>::pw;

vector<int> topological_sort(const vector<vector<int>>& graph){
  // if graph is not DAG, return {}
  // else topological sorted vertices
  int N = graph.size();
  stack<int> st;
  vector<int> h(N), res;
  for(int i = 0; i < N; i++)
    for(auto& v: graph[i]) h[v]++;
  for(int i = 0; i < N; i++)
    if(h[i] == 0) st.push(i);
  while(st.size()) {
    int u = st.top(); st.pop();
    res.push_back(u);
    for(auto& v: graph[u]){
      h[v]--;
      if(h[v] == 0) st.push(v);
    }
  }
  if(res.size() != N) res.clear();
  return res;
}

void abc_135(){
  string S,T;
  cin >> S >> T;
  ll N, M;
  N = S.size(); M = T.size();
  ll sz = 2 * max(M,N);
  string W(sz, ' ');
  rep(i,sz) W[i] = S[i%N];
  RollingHash<HashTuple>::init(sz);
  RollingHash<HashTuple> rh1(W), rh2(T);
  vvi g(N);
  auto h2 = rh2.hash(0,M);
  rep(i,N){
    auto h1 = rh1.hash(i,i+M);
    if(h1 == h2) g[i].pb((i+M)%N);
  }
  dump(g);
  auto ts = topological_sort(g);
  if(ts.size() != N){
    cout << -1 << endl;
    return;
  }
  vl dp(N);
  for(auto u:ts){
    for(auto v:g[u]) chmax(dp[v], dp[u]+1LL);
  }
  cout << *max_element(ALL(dp)) << endl;
}

int main(){
  abc_135();
  return 0;
}


Measured memory_bytes: 168200