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

struct SuffixArray {
  vector<int> sa;
  SuffixArray(string &s) {
    sa = sa_is(s);
  }
  int operator[](int k) {
    return sa[k];
  }
  vector<int> sa_is(string &s) {
    vector<char> c(s.begin(), s.end());
    c.push_back('\0');
    return sa_is(c, 256);
  }
  template <typename T>
  vector<int> sa_is(vector<T> &s, int k) {
    int n = s.size();
    vector<bool> t(n);
    t[n - 1] = 1;
    for (int i = n - 2; i >= 0; i--) {
      t[i] = s[i] < s[i + 1] || s[i] == s[i + 1] && t[i + 1];
    }
    vector<int> lmss;
    for (int i = 0; i < n; i++) {
      if (is_lms(t, i)) lmss.push_back(i);
    }
    vector<int> sa;
    {
      vector<int> r = induced_sort(s, k, t, lmss);
      for (int i = 0; i < n; i++) {
        if (is_lms(t, r[i])) sa.push_back(r[i]);
      }
    }
    vector<pair<int, int>> pa;
    int num = 0;
    pa.emplace_back(sa[0], 0);
    for (int i = 0; i < sa.size() - 1; i++) {
      int j = sa[i], k = sa[i + 1];
      bool diff = false;
      for (int d = 0; d < n; d++) {
        if (s[j + d] != s[k + d] || is_lms(t, j + d) != is_lms(t, k + d)) {
          diff = true;
          break;
        } else if (d > 0 && (is_lms(t, j + d) || is_lms(t, k + d))) {
          break;
        }
      }
      pa.emplace_back(k, diff ? ++num : num);
    }
    sort(pa.begin(), pa.end());
    vector<int> nums;
    for (auto p : pa) {
      nums.push_back(p.second);
    }
    if (num + 1 < nums.size()) {
      sa = sa_is(nums, num + 1);
    } else {
      sa.resize(nums.size());
      for (int i = 0; i < nums.size(); i++) {
        sa[nums[i]] = i;
      }
    }
    vector<int> seed;
    for (int i = 0; i < sa.size(); i++) {
      seed.push_back(lmss[sa[i]]);
    }
    return induced_sort(s, k, t, seed);
  }
  template <typename T>
  vector<int> induced_sort(vector<T> &s, int k, vector<bool> &t, vector<int> &lmss) {
    int n = s.size();
    vector<int> sa(n, -1);
    vector<int> bin(k + 1);
    for (int i = 0; i < n; i++) bin[s[i] + 1]++;
    partial_sum(bin.begin(), bin.end(), bin.begin());
    {
      vector<int> cnt(k);
      for (int i = lmss.size() - 1; i >= 0; i--) {
        auto c = s[lmss[i]];
        sa[bin[c + 1] - cnt[c] - 1] = lmss[i];
        cnt[c]++;
      }
    }
    {
      vector<int> cnt(k);
      for (int i = 0; i < n; i++) {
        if (sa[i] <= 0 || t[sa[i] - 1]) continue;
        auto c = s[sa[i] - 1];
        sa[bin[c] + cnt[c]] = sa[i] - 1;
        cnt[c]++;
      }
    }
    {
      vector<int> cnt(k);
      for (int i = n - 1; i >= 0; i--) {
        if (sa[i] <= 0 || !t[sa[i] - 1]) continue;
        auto c = s[sa[i] - 1];
        sa[bin[c + 1] - cnt[c] - 1] = sa[i] - 1;
        cnt[c]++;
      }
    }
    return sa;
  }
  inline bool is_lms(vector<bool> &t, int i) {
    return i > 0 && t[i] && !t[i - 1];
  }
};

struct UnionFind {
  vector<int> data;
  UnionFind(int n) {
    data.assign(n, -1);
  }
  int root(int k) {
    if (data[k] < 0) return k;
    return data[k] = root(data[k]);
  }
  bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int size(int k) {
    return -data[root(k)];
  }
};

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
 
  string ss = s;
  while (ss.size() < t.size()) ss += s;
  ss += ss;
  SuffixArray sa(ss);
  int sn = ss.size();
  int ll, rr;
  {
    int l = 0, r = sn + 1;
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (ss.compare(sa[m], t.size(), t) < 0) l = m;
      else r = m;
    }
    ll = r;
  }
  {
    int l = 0, r = sn + 1;
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (ss.compare(sa[m], t.size(), t) <= 0) l = m;
      else r = m;
    }
    rr = r;
  }
  auto uf = UnionFind(n);
  for (int i = ll; i < rr; i++) {
    int x = sa[i];
    if (x >= n) continue;
    int y = (x + t.size()) % n;
    if (!uf.unite(x, y)) {
      cout << -1 << endl;
      return 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i) - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 45700