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

struct SuffixArray {
  vector< int > SA;
  const string s;

  SuffixArray(const string &str) : s(str) {
    SA.resize(s.size());
    iota(begin(SA), end(SA), 0);
    sort(begin(SA), end(SA), [&](int a, int b) {
      return s[a] == s[b] ? a > b : s[a] < s[b];
    });
    vector< int > classes(s.size()), c(s.begin(), s.end()), cnt(s.size());
    for(int len = 1; len < s.size(); len <<= 1) {
      for(int i = 0; i < s.size(); i++) {
        if(i > 0 && c[SA[i - 1]] == c[SA[i]] && SA[i - 1] + len < s.size() && c[SA[i - 1] + len / 2] == c[SA[i] + len / 2]) {
          classes[SA[i]] = classes[SA[i - 1]];
        } else {
          classes[SA[i]] = i;
        }
      }
      iota(begin(cnt), end(cnt), 0);
      copy(begin(SA), end(SA), begin(c));
      for(int i = 0; i < s.size(); i++) {
        int s1 = c[i] - len;
        if(s1 >= 0) SA[cnt[classes[s1]]++] = s1;
      }
      classes.swap(c);
    }
  }

  int operator[](int k) const {
    return SA[k];
  }

  size_t size() const {
    return s.size();
  }

  bool lt_substr(const string &t, int si = 0, int ti = 0) {
    int sn = (int) s.size(), tn = (int) t.size();
    while(si < sn && ti < tn) {
      if(s[si] < t[ti]) return true;
      if(s[si] > t[ti]) return false;
      ++si, ++ti;
    }
    return si >= sn && ti < tn;
  }

  int lower_bound(const string &t) {
    int low = -1, high = (int) SA.size();
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    return high;
  }

  pair< int, int > lower_upper_bound(string &t) {
    int idx = lower_bound(t);
    int low = idx - 1, high = (int) SA.size();
    t.back()++;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    t.back()--;
    return {idx, high};
  }

  void output() {
    for(int i = 0; i < size(); i++) {
      cout << i << ": " << s.substr(SA[i]) << endl;
    }
  }
};

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> sa;
    {
      auto 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);
  }
  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;
  SuffixArray sa(ss);
  // SA_IS sa(ss);
  int sn = ss.size();
  int ll, rr;
  tie(ll, rr) = sa.lower_upper_bound(t);
  // 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: 34612