#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

struct suffix_array {
  const string& S;
  int n;
  vector<int> sa;
  suffix_array(const string& S_)
      : S(S_), n(S.size()), sa(n) {
    vector<int> r(n), t(n);
    for (int i = 0; i < n; ++i) r[sa[i] = i] = S[i];
    for (int h = 1; t[n - 1] != n - 1; h *= 2) {
      auto cmp = [&](int i, int j) {
        if (r[i] != r[j]) return r[i] < r[j];
        return i + h < n && j + h < n ? r[i + h] < r[j + h] : i > j;
      };
      sort(sa.begin(), sa.end(), cmp);
      for (int i = 0; i + 1 < n; ++i) t[i + 1] = t[i] + cmp(sa[i], sa[i + 1]);
      for (int i = 0; i < n; ++i) r[sa[i]] = t[i];
    }
  }
  int lower_bound(const string& T) const {
    auto it = partition_point(sa.begin(), sa.end(), [&](int x) {
      return S.compare(x, T.length(), T) < 0;
    });
    return distance(sa.begin(), it);
  }
  int upper_bound(const string& T) const {
    auto it = partition_point(sa.begin(), sa.end(), [&](int x) {
      return S.compare(x, T.length(), T) <= 0;
    });
    return distance(sa.begin(), it);
  }
  vector<int> find_pattern_all(const string& T) const {
    int lb = lower_bound(T);
    int ub = upper_bound(T);
    return vector<int>(sa.begin() + lb, sa.begin() + ub);
  }
};

struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n)
      : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v) return false;
    if (parent[u] > parent[v]) swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool find(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S, T;
  while (cin >> S >> T) {
    int L = S.size() + T.size() - 1;
    string P = "";
    while (P.size() < L) P += S;
    P.resize(L);
    suffix_array sa(P);
    auto pat = sa.find_pattern_all(T);
    UnionFind uf(S.size());
    bool inf = false;
    for (int x : pat) {
      assert(x < S.size());
      int y = (x + T.size()) % S.size();
      if (!uf.unite(x, y)) {
        inf = true;
        break;
      }
    }
    if (inf) {
      cout << -1 << endl;
    } else {
      int res = 0;
      for (int i = 0; i < S.size(); i++) res = max(res, uf.size(i) - 1);
      cout << res << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 16584