// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
#include <array>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>
template < int n, class... T >
typename std::enable_if< (n >= sizeof...(T)) >::type __output_tuple(
    std::ostream &, std::tuple< T... > const &) {}
template < int n, class... T >
typename std::enable_if< (n < sizeof...(T)) >::type __output_tuple(
    std::ostream &os, std::tuple< T... > const &t) {
  os << (n == 0 ? "" : ", ") << std::get< n >(t);
  __output_tuple< n + 1 >(os, t);
}
template < class... T >
std::ostream &operator<<(std::ostream &os, std::tuple< T... > const &t) {
  os << "(";
  __output_tuple< 0 >(os, t);
  os << ")";
  return os;
}
template < class T, class U >
std::ostream &operator<<(std::ostream &os, std::pair< T, U > const &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template < class T >
std::ostream &operator<<(std::ostream &os, const std::stack< T > &a) {
  os << "{";
  for(auto tmp = a; tmp.size(); tmp.pop())
    os << (a.size() == tmp.size() ? "" : ", ") << tmp.top();
  os << "}";
  return os;
}
template < class T, class Container, class Compare >
std::ostream &operator<<(std::ostream &os,
    std::priority_queue< T, Container, Compare > a) {
  os << "{ (top) ";
  while(a.size()) os << a.top() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
template < class T, class Container >
std::ostream &operator<<(std::ostream &os, std::queue< T, Container > a) {
  os << "{ ";
  while(a.size()) os << a.front() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
#ifdef DEBUG
#if !defined(DEBUG_OUT)
// #define DEBUG_OUT std::cerr
#endif
#define dump(...)                                                                \
  [&]() {                                                                        \
    auto __debug_tap = std::make_tuple(__VA_ARGS__);                             \
    DEBUG_OUT << "[" << __LINE__ << "] " << #__VA_ARGS__ << " = " << __debug_tap \
    << std::endl;                                                      \
  }()
template < class T >
inline void dump2D(T &d, size_t sizey, size_t sizex) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << "\t";
    for(size_t j = 0; j < sizex; j++)
      DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t");
    DEBUG_OUT << std::endl;
  }
}
template < class T >
inline void dump1D(T &d, size_t sizey) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << d[i] << (i + 1 == sizey ? "" : " ");
  }
  DEBUG_OUT << std::endl;
}
template <
class T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,
      class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >
      std::ostream &operator<<(std::ostream &os, const T &a) {
        os << "{";
        for(auto ite = begin(a); ite != end(a); ++ite)
          os << (ite == begin(a) ? "" : ", ") << *ite;
        os << "}";
        return os;
      }
#else
#define dump(...) ((void) 42)
#define dump2D(...) ((void) 42)
#define dump1D(...) ((void) 42)
template <
class T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,
      class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >
      std::ostream &operator<<(std::ostream &os, const T &a) {
        for(auto ite = begin(a); ite != end(a); ++ite)
          os << (ite == begin(a) ? "" : " ") << *ite;
        return os;
      }
#endif
// }}}


// t * i is in s * j
// max i s.t. t * i is in s * inf

// mystring( <string-like> )
// .shift(ll n)
// .push_front(c)
// .changeAt(index, from, to)
// [ll index] -= , +=
/// --- HashString with rolling-hash {{{ ///

// #include <functional>
#include <iterator>
#include <string>
#include <vector>

template < int N, int mod, int* B, int SZ >
class HashString {
  static_assert(N >= 1, "N must be positive");

  class PowTable {
  public:
    int table[SZ][(N + 1) * 2 + 1];
    PowTable() {
      for(int i = 0; i < SZ; i++) {
        table[i][N] = 1;
        for(int j = 1; j <= N; j++) {
          table[i][j + N] = (ll) table[i][j - 1 + N] * B[i] % mod;
        }
        table[i][N - 1] = modinv(B[i]);
        for(int j = -2; j >= -N; j--) {
          table[i][j + N] = (ll) table[i][j + 1 + N] * table[i][N - 1] % mod;
        }
      }
    }
  };
  static PowTable table;

public:
  static int modpow(int x, ll y) {
    int r = 1;
    if(y < 0) y = -y, x = modinv(x);
    while(y) {
      if(y & 1) r = (ll) r * x % mod;
      x = (ll) x * x % mod;
      y >>= 1;
    }
    return r;
  }
  static int extgcd(int a, int b, int& x, int& y) {
    int d;
    return b == 0 ? (x = a < 0 ? -1 : 1, y = 0, a < 0 ? -a : a)
      : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
  }
  static int modinv(int a) {
    int x, y;
    extgcd(a, mod, x, y);
    if(x < mod) x += mod;
    return x;
  }

  int hashed[SZ] = {};

  HashString() {}
  HashString(const char* str) : HashString(str, str + char_traits< char >::length(str)) {}
  HashString(const string& str) : HashString(str.begin(), str.end()) {}
  template < class T >
    HashString(const vector< T >& v) : HashString(v.begin(), v.end()) {}

  template < class InputIter, class = typename iterator_traits< InputIter >::value_type >
    HashString(const InputIter& first, const InputIter& last) {
      for(int i = 0; i < SZ; i++) {
        ll tmp = 1;
        for(InputIter now = first; now != last; ++now, tmp = tmp * B[i] % mod) {
          hashed[i] = (hashed[i] + tmp * ll(*now) % mod) % mod;
        }
      }
    }

  class Accessor {
    const ll n;
    HashString& str;

  public:
    Accessor(ll n, HashString& str) : n(n), str(str) {}
    template < class T >
      void operator+=(T c) {
        for(ll i = 0; i < SZ; i++) {
          ll bn = -N <= n && n <= N ? table.table[i][n + N] : modpow(B[i], n);
          str.hashed[i] = (str.hashed[i] + bn * ll(c) % mod + mod) % mod;
        }
      }
    template < class T >
      void operator-=(T c) {
        *this += -ll(c);
      }
    void operator+=(const HashString& a) {
      for(ll i = 0; i < SZ; i++) {
        ll bn = -N <= n && n <= N ? table.table[i][n + N] : modpow(B[i], n);
        str.hashed[i] = (str.hashed[i] + bn * a.hashed[i] % mod + mod) % mod;
      }
    }
    void operator-=(const HashString& a) {
      for(ll i = 0; i < SZ; i++) {
        ll bn = -N <= n && n <= N ? table.table[i][n + N] : modpow(B[i], n);
        str.hashed[i] = (str.hashed[i] - bn * a.hashed[i] % mod + mod) % mod;
      }
    }
  };

  Accessor operator[](ll i) { return Accessor(i, *this); }

  void shift(ll n = 1) {
    for(int i = 0; i < SZ; i++) {
      ll bn = -N <= n && n <= N ? table.table[i][n + N] : modpow(B[i], n);
      hashed[i] = (ll) hashed[i] * bn % mod;
    }
  }

  bool operator==(const HashString& a) const {
    for(int i = 0; i < SZ; i++) {
      if(hashed[i] != a.hashed[i]) return 0;
    }
    return 1;
  }

  HashString& operator+=(const HashString& a) {
    for(int i = 0; i < SZ; i++) {
      hashed[i] += a.hashed[i];
      if(hashed[i] >= mod) hashed[i] -= mod;
    }
    return *this;
  }

  HashString& operator-=(const HashString& a) {
    for(int i = 0; i < SZ; i++) {
      hashed[i] += mod - a.hashed[i];
      if(hashed[i] >= mod) hashed[i] -= mod;
    }
    return *this;
  }

  HashString operator+(const HashString& a) const {
    HashString tmp = *this;
    tmp += a;
    return tmp;
  }

  HashString operator-(const HashString& a) const {
    HashString tmp = *this;
    tmp -= a;
    return tmp;
  }

  template < class T >
    void push_front(const T& a) {
      for(int i = 0; i < SZ; i++) {
        hashed[i] = (ll) hashed[i] * B[i] % mod;
        hashed[i] = (hashed[i] + ll(a)) % mod;
      }
    }

  template < class T >
    void changeAt(ll n, T a, T b) {
      for(int i = 0; i < SZ; i++) {
        ll bn = -N <= n && n <= N ? table.table[i][n + N] : modpow(B[i], n);
        hashed[i] = (hashed[i] + (mod + ll(b) - ll(a)) * bn % mod) % mod;
      }
    }

  friend ostream& operator<<(ostream& os, const HashString& a) {
    // HASH_STRING{, }
    os << "HASH_STRING{" << a.hashed[0];
    for(int i = 1; i < SZ; i++) {
      os << ", " << a.hashed[i];
    }
    os << "}";
    return os;
  }
};
template < int N, int mod, int* B, int SZ >
typename HashString< N, mod, B, SZ >::PowTable HashString< N, mod, B, SZ >::table;

constexpr int _hs_N = 1e6;

int _hs_B[] = {
  114514, 1919, 810,
};

using mystring =
HashString< _hs_N, 1'000'000'007, _hs_B, sizeof(_hs_B) / sizeof(_hs_B[0]) >;

namespace std {
  template < int N, int mod, int* B, int SZ >
    struct hash< HashString< N, mod, B, SZ > > {
      template < class T >
        static void hash_combine(size_t& seed, T const& v) {
          seed ^= hash< T >{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        }
      size_t operator()(const HashString< N, mod, B, SZ >& a) {
        size_t seed = 0;
        for(int i = 0; i < SZ; i++) {
          hash_combine(seed, a.hashed[i]);
        }
        return seed;
      }
    };
} // namespace std

/// }}}--- ///

vector<int> where;

constexpr int inf = 1e9;
vector<int> used;
vector<int> memo;

int dfs(int i){
  if(where[i] == -1) return 0;
  if(used[i] == 1) return memo[i];
  if(used[i] == 2) return inf;
  used[i] = 2;

  int res = 0;

  res = dfs(where[i]);

  if(res != inf) res++;

  used[i] = 1;
  return memo[i] = res;
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s, t;
  cin >> s >> t;
  string s2 = "";
  for(int i = 0; i < t.size(); i++) {
    s2 += s[i % s.size()];
  }
  mystring ms(s2);
  mystring mt(t);
  where = vector<int>(s.size(), -1);
  used.resize(s.size());
  memo.resize(s.size());
  for(int i = 0; i < s.size(); i++) {
    dump(i, ms == mt);
    if(ms == mt) where[i] = (i + t.size()) % s.size();
    ms.changeAt(0, s[i], char(0));
    // ms.changeAt(t.size(), s[i], char(0));
    ms.shift(-1);
    ms.changeAt(t.size() - 1, char(0), s[(i + t.size()) % s.size()]);
    // ms.changeAt(0, char(0), s[(i + t.size()) % s.size()]);
  }
  int ma = 0;
  for(int i = 0; i < s.size(); i++) ma = max(ma, dfs(i));
  if(ma == inf) ma = -1;
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 39032