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

struct SA_IS {
  vector<int> sa;
  SA_IS(string s) {
    sa = sa_is(s);
  }
  inline bool is_lms(vector<bool> &t, int i) {
    return i > 0 && t[i] && !t[i - 1];
  }
  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;
  }
  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> seed = lmss;
    vector<int> tsa = induced_sort(s, k, t, seed);
    
    vector<int> sa;
    for (int i = 0; i < n; i++) {
      if (is_lms(t, tsa[i])) sa.push_back(tsa[i]);
    }

    map<int, int> ma;
    int num = 0;
    ma[sa[0]] = num;

    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;
        }
      }
      ma[k] = diff ? ++num : num;
    }

    vector<int> nums;
    for (auto m : ma) {
      nums.push_back(m.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;
      }
    }
    seed = {};
    for (int i = 0; i < sa.size(); i++) {
      seed.push_back(lmss[sa[i]]);
    }
    return induced_sort(s, k, t, seed);
  }
  vector<int> sa_is(string &s) {
    vector<char> c(s.begin(), s.end());
    c.push_back('\0');
    return sa_is(c, 256);
  }
  int operator[](int k) {
    return sa[k];
  }
};

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;
  SA_IS 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: 126472