#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

struct RollingHash {
    const int base = 9348;
    const int mod[2] = {999999937, 1000000007};
    vector<int> s;
    vector<ll> hash[2], pow[2];

    RollingHash(const vector<int> &cs) : s(cs) {
        int n = s.size();
        for (int id = 0; id < 2; ++id) {
            hash[id].assign(n+1, 0);
            pow[id].assign(n+1, 1);
            for (int i = 0; i < n; ++i) {
                hash[id][i+1] = (hash[id][i] * base + s[i]) % mod[id];
                pow[id][i+1] = pow[id][i] * base % mod[id];
            }
        }
    }

    RollingHash(const string &s) {
      vi tmp;
      for(int i=0;i<SZ(s);++i) {
        tmp.push_back(s[i]);
      }
      int n = s.size();
        for (int id = 0; id < 2; ++id) {
            hash[id].assign(n+1, 0);
            pow[id].assign(n+1, 1);
            for (int i = 0; i < n; ++i) {
                hash[id][i+1] = (hash[id][i] * base + s[i]) % mod[id];
                pow[id][i+1] = pow[id][i] * base % mod[id];
            }
        }
    }

    // get hash of s[l:r)
    ll get(int l, int r, int id = 0) {
        ll res = hash[id][r] - hash[id][l] * pow[id][r-l] % mod[id];
        if (res < 0) res += mod[id];
        return res;
    }
};

class TopologicalSort {
  using Graph = std::vector<std::vector<int>>;
  // 頂点数
  int V;
  std::vector<std::vector<int>> G;
  void dfs(int v, std::vector<int> &res, std::vector<int> &used) {
    used[v] = 1;
    for (auto to : G[v])
      if (used[to] == 0) {
        dfs(to, res, used);
      }
    res.push_back(v);
  }

 public:
  TopologicalSort(int _v) : V(_v), G(_v) {}
  void addEdge(int a, int b) {
    assert(0 <= a && a < V);
    assert(0 <= b && b < V);
    G[a].push_back(b);
  }
  std::vector<int> topologicalSort() {
    std::vector<int> ide(V);
    for (int i = 0; i < V; i++) {
      for (auto to : G[i]) {
        ide[to]++;
      }
    }
    std::vector<int> res;
    std::vector<int> used(V);
    for (int i = V - 1; i >= 0; i--) {
      if (ide[i] == 0) {
        dfs(i, res, used);
      }
    }
    if (res.size() == 0) res = {-1};
    reverse(res.begin(), res.end());
    return res;
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s, t; cin >> s >> t;
  string tmps = "";
  while(SZ(tmps) <= SZ(t) + SZ(s) + 1) tmps += s;
  RollingHash rh1(tmps), rh2(t);

  int szs = SZ(s), sztmps = SZ(tmps), szt = SZ(t);

  TopologicalSort ts(SZ(s));
  vvi g(szs);

  for(int i=0;i<szs;++i) {
    if(rh1.get(i, i + szt) == rh2.get(0, szt)) {
      ts.addEdge(i, (i + szt) % szs);
      g[i].push_back((i+szt) % szs);
    }
  }

  vi res = ts.topologicalSort();
  if(res[0] == -1 || SZ(res) != szs) {
    cout << -1 << endl;
    return 0;
  }
  reverse(res.begin(), res.end());

  map<int, int> mp;
  for(int i=0;i<szs;++i) {
    mp[res[i]] = i;
  }

  vi dp(szs, 0);
  int ans = 0;
  for(int i=1;i<szs;++i) {
    int now = res[i];
    for(int j=0;j<SZ(g[now]);++j) {
      int to = g[now][j];
      dp[i] = max(dp[i], dp[mp[to]] + 1);
      ans = max(ans, dp[i]);
    }
  }
/*   printv(res);
  printv(dp); */

  cout << ans << endl;

}


Measured memory_bytes: 127200