#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

class RollingHash {
  using ulint = unsigned long long;
  const ulint mod = (1ULL << 61) - 1, mod3 = mod * ((1UL << 3) - 1), m30 = (1ULL << 30) - 1, m31 = (1ULL << 31) - 1;
  const unsigned base;
  vector<ulint>  hash, lookup;
  ulint mul(ulint a, ulint b) const {
    ulint au = a >> 31, ad = a & m31, bu = b >> 31, bd = b & m31;
    ulint m = ad * bu + au * bd, mu = m >> 30, md = m & m30;
    return au * bu * 2 + mu + (md << 31) + ad * bd;
  }
  ulint modulo(ulint x) const {
    if ((x = (x & mod) + (x >> 61)) > mod) x -= mod;
    return x;
  }

  public:
  RollingHash(void) : base(10007) {}
  RollingHash(const string &s, const unsigned base = 10007) : base(base) { init(s); }
  void init(const string &s) {
    const int len = s.length();
    hash.assign(len + 1, 0);
    lookup.assign(len + 1, 0);
    lookup[0] = 1;
    for (int i = 0; i < len; ++i) {
      hash[i + 1]   = modulo(mul(hash[i], base) + s[i]);
      lookup[i + 1] = modulo(mul(lookup[i], base));
    }
  }
  ulint get(const int l, const int r) const {
    return modulo(hash[r] + (mod3 - mul(hash[l], lookup[r - l])));
  }
  bool same(const int a_begin, const int a_end, const int b_begin, const int b_end) const {
    if (a_end - a_begin != b_end - b_begin) return false;
    return get(a_begin, a_end) == get(b_begin, b_end);
  }
  bool same(const int a_begin, const int a_end, const int b_begin, const int b_end, const RollingHash &b_rh) const {
    if (a_end - a_begin != b_end - b_begin) return false;
    assert(base == b_rh.base);
    return get(a_begin, a_end) == b_rh.get(b_begin, b_end);
  }
};

int main(void) {
  string s, t;
  cin >> s >> t;
  int slen = s.length(), tlen = t.length();
  string s2;
  while ((int)s2.length() < tlen) s2 += s;
  s2 += s2;
  vector<bool> ok(slen);
  RollingHash  srh(s2), trh(t);
  rep (i, slen) {
    if (srh.same(i, i + tlen, 0, tlen, trh)) ok[i] = true;
    // if (equal(s2.begin() + i, s2.begin() + i + tlen, t.begin())) ok[i] = true;
  }
  int maxi = 0;
  vector<bool> checked(slen);
  rep (i, slen) {
    if (!ok[i] || checked[i]) continue;
    int j = i, sum = 0;
    vector<bool> loopcheck(slen);
    while (1) {
      if (ok[j]) {
        if (loopcheck[j]) {
          cout << -1 << endl;
          return 0;
        }
        ++sum;
        checked[j]   = true;
        loopcheck[j] = true;
      } else {
        break;
      }
      j = (j + tlen) % slen;
    }
    maxi = max(maxi, sum);
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 42824