#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename T = string>
struct RollingHash {
  T str;

  RollingHash(const T &s, const int base = 10007, const int md = 1000000007) : str(s), base(base), md(md) {
    int n = str.size();
    hash_val.resize(n + 1);
    hash_val[0] = 0;
    power.resize(n + 1);
    power[0] = 1;
    REP(i, n) {
      hash_val[i + 1] = (hash_val[i] * base % md + str[i]) % md;
      power[i + 1] = power[i] * base % md;
    }
  }

  long long get(int left, int right) {
    long long res = hash_val[right] - hash_val[left] * power[right - left] % md;
    return res < 0 ? res + md : res;
  }

  void add(const T &t) {
    for (auto c : t) {
      hash_val.emplace_back((hash_val.back() * base % md + c) % md);
      power.emplace_back(power.back() * base % md);
    }
  }

  int lcp(int i, int j) {
    int n = str.size(), lb = 0, ub = n + 1 - max(i, j);
    while (ub - lb > 1) {
      int mid = (lb + ub) >> 1;
      (get(i, i + mid) == get(j, j + mid) ? lb : ub) = mid;
    }
    return lb;
  }

  template <typename U>
  int lcp(const RollingHash<U> &t, int i, int j) {
    int lb = 0, ub = min(static_cast<int>(str.size()) - i, static_cast<int>(t.str.size()) - j) + 1;
    while (ub - lb > 1) {
      int mid = (lb + ub) >> 1;
      (get(i, i + mid) == t.get(j, j + mid) ? lb : ub) = mid;
    }
    return lb;
  }

private:
  int base, md;
  vector<long long> hash_val, power;
};

struct MP {
  vector<int> border;

  MP(const string &s) : str(s) {
    int n = str.length();
    border.assign(1, -1);
    REP(i, n) solve(i);
  }

  void add(char c) {
    int idx = str.length();
    str += c;
    solve(idx);
  }

  vector<int> match(const string &t) {
    int n = str.length(), m = t.length();
    vector<int> res;
    int k = 0;
    REP(i, m) {
      while (k >= 0 && t[i] != str[k]) k = border[k];
      if (++k == n) res.emplace_back(i - n + 1);
    }
    return res;
  }

  int period(int idx) { return idx - border[idx]; }

private:
  int j = -1;
  string str;

  void solve(int idx) {
    while (j >= 0 && str[idx] != str[j]) j = border[j];
    border.emplace_back(++j);
  }
};

int main() {
  string s, t; cin >> s >> t;
  int t_len = t.length();
  string S = "", T = t + t;
  while (S.length() + 1 < s.length() + t_len) S += s;
  REP(_, 10) S += s;
  RollingHash<> rh_s(S), rh_T(t);
  bool ans = false;
  for (int i = 0; i + t_len - 1 < S.length(); ++i) {
    if (rh_s.get(i, i + t_len) == rh_T.get(0, t_len)) {
      ans = true;
      break;
    }
  }
  if (!ans) {
    cout << "0\n";
    return 0;
  }
  MP mp_s(S), mp_T(T);
  if (mp_s.period(S.length()) == mp_T.period(T.length())) {
    cout << "-1\n";
    return 0;
  }
  int lb = 1, ub = S.length() / t_len + 1;
  string T2 = "";
  REP(_, ub - 1) T2 += t;
  RollingHash<> rh_T2(T2);
  while (ub - lb > 1) {
    int mid = (lb + ub) >> 1;
    bool ok = false;
    for (int i = 0; i + t_len * mid - 1 < S.length(); ++i) {
      if (rh_s.get(i, i + t_len * mid) == rh_T2.get(0, t_len * mid)) {
        ok = true;
        break;
      }
    }
    (ok ? lb : ub) = mid;
  }
  cout << lb << '\n';
  return 0;
}


Measured memory_bytes: 278996