#include <bits/stdc++.h>
#define loop(m) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(m); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

template < template < typename ... > class Container, typename Value >
auto make_z_array(Container< Value > const & s) -> std::vector< int > {
  if (s.empty()) return {};
  auto m = (int)s.size();
  std::vector< int > ret(m);
  ret.at(0) = m;
  auto i = 1, j = 0;
  while (i < m) {
    while (i + j < m && s.at(j) == s.at(i + j))
      { j++; }
    ret.at(i) = j;
    if (j == 0)
      { i++; }
    else {
      auto k = 1;
      while (i + k < m && k + ret.at(k) < j) {
        ret.at(i + k) = ret.at(k);
        k++;
      }
      i += k, j -= k;
    }
  }
  return ret;
}

// Returns turns all the occurence of w in s.
template < template < typename ... > class Container, typename Value >
auto z_search(Container< Value > const & w, Container< Value > const & s, Value dammy) -> std::vector<int> {
  if (s.empty()) return {};
  assert(!w.empty());
  assert(std::find(w.begin(), w.end(), dammy) == w.end());
  assert(std::find(s.begin(), s.end(), dammy) == s.end());
  auto long_string = w;
  long_string.push_back(dammy);
  long_string.insert(long_string.end(), s.begin(), s.end());
  auto z_array = make_z_array(std::move(long_string));
  int n = w.size(), m = s.size();
  std::vector<int> ret;
  for (int i = 0; i < m; i++) {
    if (z_array.at(n + 1 + i) == n)
      { ret.push_back(i); }
  }
  return ret;
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s, t; std::cin >> s >> t;
  while(s.length() < t.length())
    { s += s; }
  int m = s.length();
  int n = t.length();
  s += s;
  std::vector< int > a(m, false);
  for (auto x : z_search(t, s, '$')) {
    if (m <= x) break;
    a.at(x) = true;
  }
  auto g = std::__gcd(m, n);
  auto N = 2 * m / g;
  auto ret = 0;
  rep(start, 0, g) {
    auto now = 0;
    auto j = start;
    rep(i, 0, N) {
      (j += n) %= m;
      if (!a.at(j))
        { now = 0;}
      else
        { cmx(ret, ++now); }
    }
  }
  if (ret == N)
    { ret = -1; }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 30424