#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

vector<int> kmp(string s) {
  int n = s.size();
  vector<int> p(n + 1);
  p[0] = -1;
  int j = -1;
  for (int i = 0; i < n; i++) {
    while (j != -1 && s[i] != s[j]) j = p[j];
    p[i + 1] = ++j;
  }
  return p;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  const int n = s.size();
  const int m = t.size();
  vector<bool> match(n);
  int u = 0;
  auto pre = kmp(t);
  rep(i, n + m) {
    while (u != -1 && t[u] != s[i % n]) u = pre[u];
    u++;
    if (u == m) {
      match[(i+1-m) % n] = true;
    }
  }
  vector<vector<int>> g(n);
  vector<int> deg(n);
  rep(i, n) {
    if (match[i]) {
      int j = (i + m) % n;
      g[i].push_back(j);
      deg[j]++;
    }
  }
  queue<int> q;
  rep(i, n) if (deg[i] == 0) q.push(i);
  vector<int> dp(n);
  int num = 0;
  while (!q.empty()) {
    num++;
    int u = q.front(); q.pop();
    for (int v : g[u]) {
      dp[v] = max(dp[v], dp[u] + 1);
      if (--deg[v] == 0) {
        q.push(v);
      }
    }
  }
  if (num != n) {
    cout << -1 << endl;
  } else {
    cout << *max_element(dp.begin(), dp.end()) << endl;
  }
}