#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>

template <typename ForwardIt, class BinaryPredicate = std::equal_to<>>
class z_array {
public:
  using size_type = size_t;
  using value_type = typename ForwardIt::value_type;

private:
  std::vector<value_type> M_pat;
  std::vector<size_type> M_z;
  BinaryPredicate M_pred;

public:
  z_array(ForwardIt pat_first, ForwardIt pat_last,
          BinaryPredicate pred = BinaryPredicate()):
    M_pat(pat_first, pat_last), M_z(M_pat.size()), M_pred(pred)
  {
    if (pat_first == pat_last) return;
    M_z[0] = M_pat.size();
    for (size_type i = 1, j = 0; i < M_pat.size();) {
      while (i+j < M_pat.size() && M_pred(M_pat[j], M_pat[i+j])) ++j;
      M_z[i] = j;
      if (j == 0) {
        ++i;
        continue;
      }
      size_type k = 1;
      while (i+k < M_pat.size() && k+M_z[k] < j) M_z[i+k] = M_z[k], ++k;
      i += k;
      j -= k;
    }
  }

  template <typename ForwardIt2>
  std::vector<std::pair<ForwardIt2, ForwardIt2>> search_all(
      ForwardIt2 first, ForwardIt2 last
  ) const {
    if (first == last) return {{last, last}};
    std::vector<std::pair<ForwardIt2, ForwardIt2>> res;
    if (M_pat.empty()) {
      for (auto it = first; it != last; ++it) res.emplace_back(it, it);
      res.emplace_back(last, last);
      return res;
    }

    std::deque<ForwardIt2> start;
    size_type i = 0;
    size_type j = 0;
    for (auto it = first; it != last;) {
      while (it != last && j < M_pat.size() && M_pred(M_pat[j], *it)) {
        ++j;
        start.push_back(it++);
        if (start.size() > M_pat.size()) start.pop_front();
      }
      if (j == 0) {
        ++i;
        start.push_back(it++);
        if (start.size() > M_pat.size()) start.pop_front();
        continue;
      }
      if (j == M_pat.size()) res.emplace_back(start.front(), it);
      size_type k = 1;
      while (k < M_pat.size() && k+M_z[k] < j) ++k;
      i += k;
      j -= k;
    }
    return res;
  }

  template <typename ForwardIt2>
  std::pair<ForwardIt2, ForwardIt2> search_first(
      ForwardIt2 first, ForwardIt2 last
  ) const {
    if (M_pat.empty()) return {first, first};
    if (first == last) return {last, last};

    std::deque<ForwardIt2> start;
    size_type i = 0;
    size_type j = 0;
    for (auto it = first; it != last;) {
      while (it != last && j < M_pat.size() && M_pred(M_pat[j], *it)) {
        ++j;
        start.push_back(it++);
        if (start.size() > M_pat.size()) start.pop_front();
      }
      if (j == 0) {
        ++i;
        start.push_back(it++);
        if (start.size() > M_pat.size()) start.pop_front();
        continue;
      }
      if (j == M_pat.size()) return {start.front(), it};
      size_type k = 1;
      while (k < M_pat.size() && k+M_z[k] < j) ++k;
      i += k;
      j -= k;
    }
    return {last, last};
  }

  template <typename ForwardIt2>
  std::pair<ForwardIt2, ForwardIt2> operator ()(
      ForwardIt2 first, ForwardIt2 last
  ) const { return search_first(first, last); }
};

template <typename ForwardIt, typename BinaryPredicate = std::equal_to<>>
auto make_z_array(ForwardIt first, ForwardIt last,
                  BinaryPredicate pred = BinaryPredicate()) {
  return z_array<ForwardIt, BinaryPredicate>(first, last, pred);
}

template <typename ForwardIt, class BinaryPredicate = std::equal_to<>>
class knuth_morris_pratt_searcher {
public:
  using size_type = size_t;
  using value_type = typename ForwardIt::value_type;

private:
  static constexpr size_type S_npos = -1;
  std::vector<value_type> M_pat;
  std::vector<size_type> M_fail;
  BinaryPredicate M_pred;

public:
  knuth_morris_pratt_searcher(ForwardIt pat_first, ForwardIt pat_last,
                              BinaryPredicate pred = BinaryPredicate()):
    M_pat(pat_first, pat_last), M_fail(M_pat.size()+1), M_pred(pred)
  {
    M_fail[0] = S_npos;
    for (size_type i = 0, j = S_npos; i < M_pat.size();) {
      while (j != S_npos && !pred(M_pat[i], M_pat[j])) j = M_fail[j];
      ++i, ++j;
      M_fail[i] = (pred(i < M_pat.size() && M_pat[i], M_pat[j])? M_fail[j]: j);
    }
  }

  template <typename ForwardIt2>
  std::vector<std::pair<ForwardIt2, ForwardIt2>> search_all(
      ForwardIt2 first, ForwardIt2 last
  ) const {
    std::vector<std::pair<ForwardIt2, ForwardIt2>> res;
    if (M_pat.empty()) {
      for (auto it = first; it != last; ++it) res.emplace_back(it, it);
      res.emplace_back(last, last);
      return res;
    }
    std::deque<ForwardIt2> start;
    size_type j = 0;
    for (auto it = first; it != last;) {
      start.push_back(it);
      while (j != S_npos && !M_pred(M_pat[j], *it)) j = M_fail[j];
      ++it;
      if (start.size() > M_pat.size()) start.pop_front();
      if (++j == M_pat.size()) {
        res.emplace_back(start.front(), it);
        j = M_fail[j];
      }
    }
    return res;
  }

  template <typename ForwardIt2>
  std::pair<ForwardIt2, ForwardIt2> search_first(
      ForwardIt2 first, ForwardIt2 last
  ) const {
    if (M_pat.empty()) return {first, first};
    size_type j = 0;
    for (auto it = first; it != last;) {
      while (j != S_npos && !M_pred(M_pat[j], *it)) j = M_fail[j];
      ++it;
      if (++j == M_pat.size()) return {std::prev(it, j), it};
    }
    return {last, last};
  }

  template <typename ForwardIt2>
  std::pair<ForwardIt2, ForwardIt2> operator ()(
      ForwardIt2 first, ForwardIt2 last
  ) const { return search_first(first, last); }
};

template <typename ForwardIt, typename BinaryPredicate = std::equal_to<>>
auto make_knuth_morris_pratt_searcher(ForwardIt first, ForwardIt last,
                                      BinaryPredicate pred = BinaryPredicate()) {
  return knuth_morris_pratt_searcher<ForwardIt, BinaryPredicate>(first, last, pred);
}

intmax_t neko(std::string const& s, std::string const& t) {
  size_t n = s.length();
  size_t m = t.length();
  auto kmp = make_knuth_morris_pratt_searcher(t.begin(), t.end());
  auto ss = s+s;
  auto res = kmp.search_all(ss.begin(), ss.end());
  std::vector<int> a(2*n);
  for (auto ri: res) ++a[ri.first-ss.begin()];
  for (size_t i = m; i < 2*n; ++i)
    if (a[i]) a[i] += a[i-m];

  int a0 = *std::max_element(a.begin(), a.begin()+n);
  int a1 = *std::max_element(a.begin()+n, a.end());
  if (a0 < a1) return -1;
  return a0;
}

int main() {
  char buf[524288];
  scanf("%s", buf);
  std::string s0 = buf;
  scanf("%s", buf);
  std::string t = buf;

  std::string s = s0;
  while (s.length() < t.length()) s += s0;

  printf("%jd\n", neko(s+s, t));
}


Measured memory_bytes: 85100