#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

vector<pair<int, int>> prime_factor(int num) {
  vector<pair<int, int>> ret;
  for (int i=2; i*i<=num; ++i) {
    int cnt = 0;
    while (num%i == 0) {
      num /= i;
      ++cnt;
    }
    if (cnt != 0) ret.push_back(make_pair(i, cnt));
  }
  if (num != 1) ret.push_back(make_pair(num, 1));
  return ret;
}

vector<int> divisor(int num) {
  vector<int> ret;
  ret.push_back(1);
  for (auto p : prime_factor(num)) {
    int sz = ret.size();
    int x, y;
    tie(x,y) = p;
    rep(i,sz) {
      int d = ret[i];
      rep(j,y) {
        d *= x;
        ret.push_back(d);
      }
    }
  }
  sort(ret.begin(), ret.end());
  ret.pop_back();
  return ret;
}

vector<int> Zalgorithm(const string &str) {
  vector<int> ret(str.size());
  ret[0] = str.size();
  int i = 1, j = 0;
  while (i < str.size()) {
    while (i+j < str.size() && str[j] == str[i+j]) ++j;
    ret[i] = j;
    if (j == 0) {
      ++i;
      continue;
    }
    int k = 1;
    while (i+k < str.size() && k+ret[k] < j) {
      ret[i+k] = ret[k];
      ++k;
    }
    i += k; j -= k;
  }
  return ret;
}

bool eternity;
vb seen, visited;

void dfs(vi &ans, const vb &portion, string &s, string &t2, int v) {
  seen[v] = true;
  if (portion[v]) {
    int nv = (v + t2.size()) % s.size();
    if (seen[nv] && !visited[nv]) {
      eternity = true;
      return;
    }
    if (!visited[nv]) {
      dfs(ans, portion, s, t2, nv);
      if (eternity) return;
    }
    ans[v] = ans[nv] + 1;
  }
  visited[v] = true;
}

void solve() {
  string s, t; cin >> s >> t;

  vi Zt = Zalgorithm(t);
  int loop = 1;
  for (auto v : divisor(t.size())) {
    if (v+Zt[v] == t.size()) {
      loop = t.size() / v;
      break;
    }
  }
  string t2 = t.substr(0, t.size() / loop);

  vb portion(s.size(), false);
  int idx = 0, cnt = 0;
  while (idx < s.size()) {
    while (cnt < t2.size() && s[(idx+cnt)%s.size()] == t2[cnt]) {
      ++cnt;
    }
    if (cnt == 0) {
      ++idx;
      continue;
    }
    if (cnt == t2.size()) {
      portion[idx] = true;
    }
    int move = 1;
    while (idx+move < s.size() && move+Zt[move] < cnt) {
      ++move;
    }
    idx += move; cnt -= move;
  }

  vi ans(s.size(), 0);
  eternity = false;
  seen.assign(s.size(), false);
  visited.assign(s.size(), false);

  rep(i,s.size()) {
    if (seen[i]) continue;
    dfs(ans, portion, s, t2, i);
    if (eternity) {
      cout << -1 << endl;
      return;
    }
  }

  cout << *max_element(all(ans)) / loop << endl;
  return;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 36892