#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Z> Z rng(Z a, Z b) {
  static mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<Z>(a, b - 1)(mt);
}

struct RollingHash {
  static constexpr uint64_t P0 = 4e9 + 7, P1 = 4e9 + 9;
  static uint64_t B0, B1;
  static V<uint64_t> powB0, powB1;
  const int n;
  V<uint64_t> h0, h1;
  template<class Itr> RollingHash(Itr first, Itr last) : n(distance(first, last)), h0(n + 1), h1(n + 1) {
    for (int i = 0; i < n; ++i, ++first) {
      h0[i + 1] = (h0[i] * B0 + *first) % P0;
      h1[i + 1] = (h1[i] * B1 + *first) % P1;
    }
    while ((int)powB0.size() <= n) {
      powB0.push_back(powB0.back() * B0 % P0);
      powB1.push_back(powB1.back() * B1 % P1);
    }
  }
  uint64_t get0(int l, int r) const { return (h0[r] + (P0 - h0[l]) * powB0[r - l]) % P0; }
  uint64_t get1(int l, int r) const { return (h1[r] + (P1 - h1[l]) * powB1[r - l]) % P1; }
  pair<uint64_t, uint64_t> get(int l, int r) const { return {get0(l, r), get1(l, r)}; }
  bool eq(int l0, int r0, int l1, int r1) const {
    return get0(l0, r0) == get0(l1, r1) and get1(l0, r0) == get1(l1, r1);
  }
  template<class Itr> static uint64_t get0(Itr first, Itr last) {
    uint64_t res = 0;
    while (first != last) {
      res = (res * B0 + *first++) % P0;
    }
    return res;
  }
  template<class Itr> static uint64_t get1(Itr first, Itr last) {
    uint64_t res = 0;
    while (first != last) {
      res = (res * B1 + *first++) % P1;
    }
    return res;
  }
};
uint64_t RollingHash::B0 = rng<unsigned>(1, RollingHash::P0);
uint64_t RollingHash::B1 = rng<unsigned>(1, RollingHash::P1);
V<uint64_t> RollingHash::powB0{1};
V<uint64_t> RollingHash::powB1{1};

int scc(const VV<>& g, V<>& comp) {
  int n = g.size();
  VV<> rg(n);
  for (int v = 0; v < n; v++) for (int w : g[v]) {
    rg[w].push_back(v);
  }
  V<> vs;
  V<bool> vis(n);
  comp.resize(n);
  auto dfs = [&](const auto& dfs, int v) -> void {
    vis[v] = true;
    for (int w : g[v]) if (!vis[w]) {
      dfs(dfs, w);
    }
    vs.push_back(v);
  };
  auto rdfs = [&](const auto& rdfs, int v, int k) -> void {
    vis[v] = true;
    comp[v] = k;
    for (int w : rg[v]) if (!vis[w]) {
      rdfs(rdfs, w, k);
    }
  };
  for (int v = 0; v < n; v++) if (!vis[v]) {
    dfs(dfs, v);
  }
  vis.assign(n, false);
  int k = 0;
  reverse(begin(vs), end(vs));
  for (int v : vs) if (!vis[v]) {
    rdfs(rdfs, v, k++);
  }
  return k;
}

struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  while (s.size() < t.size()) s += s;
  int n = s.size(), m = t.size();
  s += s;
  RollingHash rhs(begin(s), end(s)), rht(begin(t), end(t));

  V<bool> b(n);
  V<> vs;
  for (int i = 0; i < n; ++i) {
    b[i] = rhs.get(i, i + m) == rht.get(0, m);
    if (b[i]) vs.push_back(i);
  }
  if (vs.empty()) return cout << 0 << '\n', 0;

  auto zip = [&](int i) -> int { return lower_bound(begin(vs), end(vs), i) - begin(vs); };

  VV<> g(vs.size());
  for (int i = 0; i < n; ++i) if (b[i]) {
    if (n == m) return cout << -1 << '\n', 0;
    int j = (i + m) % n;
    if (b[j]) {
      g[zip(i)].push_back(zip(j));
    }
  }
  V<> comp;
  scc(g, comp);

  set<int> se;
  for (int v = 0; v < (int)g.size(); ++v) {
    if (se.count(comp[v])) return cout << -1 << '\n', 0;
    se.insert(comp[v]);
  }

  UnionFind uf(n);
  for (int v = 0; v < (int)g.size(); ++v) for (int w : g[v]) {
    uf.unite(v, w);
  }
  int res = 0;
  for (int v = 0; v < (int)g.size(); ++v) {
    res = max(res, uf.size(v));
  }
  cout << res << '\n';
}

Measured memory_bytes: 211876