#include <bits/stdc++.h>
using namespace std;

#define repr(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define irepr(i, a, b) for (int i = (a), i##_len = (b); i >= i##_len; --i)
#define irep(i, n) for (int i = (n), i >= 0; --i)

#define all(arr) begin(arr), end(arr)

#define printline(str) cout << str << "\n"

#define lint long long
#define ulint unsigned long long

template <class T>
void printArray(const T &arr, string del = string(", "))
{
  for (auto it = begin(arr); it != end(arr); it++)
  {
    cout << (it != cbegin(arr) ? del : "") << *it;
  }
  cout << "\n";
}

class BIT
{
private:
  int n;
  vector<int> nodes;

public:
  BIT(vector<int> v)
  {
    int size = v.size();
    n = 1;
    while (n < size)
    {
      n *= 2;
    }
    nodes.resize(n, 0);
    rep(i, size)
    {
      add(i, v[i]);
    }
  }

  void add(int i, int val)
  {
    ++i;
    while (i <= n)
    {
      nodes[i] += val;
      i += i & -i;
    }
  }

  int sum(int i)
  {
    ++i;
    int ret = 0;
    while (i > 0)
    {
      ret += nodes[i];
      i -= i & -i;
    }
    return ret;
  }
};

struct UnionFindTree
{
  vector<int> nodes;

  UnionFindTree(int N) : nodes(N, -1)
  {
  }
  
  int Root(int i ){
    if( nodes[i] < 0){
      return i;
    }
    return nodes[i] = Root(nodes[i]);
  }

  bool Connect(int i, int j){
    auto rootI = Root(i);
    auto rootJ = Root(j);
    if( rootI == rootJ){
      return false;
    }
    nodes[rootI] += nodes[rootJ];
    nodes[rootJ] = rootI;
    return true;
  }

};

class RollingHash
{
private:
  static constexpr int modNum = 2;
  const array<int, modNum> mod = {{999999937, 1000000007}};
  static const lint base = 9973;
  vector<lint> pw[modNum];
  RollingHash() {}

public:
  int size;
  vector<lint> hs[modNum];

  RollingHash(const string &s)
  {
    size = s.size();
    for (int i = 0; i < modNum; i++)
    {
      hs[i].assign(size + 1, 0);
      pw[i].assign(size + 1, 0);
      hs[i][0] = 0;
      pw[i][0] = 1;
      for (int j = 0; j < size; j++)
      {
        pw[i][j + 1] = pw[i][j] * base % mod[i];
        hs[i][j + 1] = (hs[i][j] * base + s[j]) % mod[i];
      }
    }
  }

  lint Hash(int l, int r, int i)
  {
    return ((hs[i][r] - hs[i][l] * pw[i][r - l]) % mod[i] + mod[i]) % mod[i];
  }

  array<lint, modNum> Hash(int l, int r){
    array<lint, modNum> ret;
    rep(i, modNum)
      ret[i] = Hash(l, r, i);
    return ret;
  }

  bool Match(int l1, int r1, int l2, int r2)
  {
    bool ret = 1;
    for (int i = 0; i < modNum; i++)
      ret &= Hash(l1, r1, i) == Hash(l2, r2, i);
    return ret;
  }

  bool Match(int l, int r, array<lint, modNum> h)
  {
    bool ret = 1;
    for (int i = 0; i < modNum; i++)
      ret &= Hash(l, r, i) == h[i];
    return ret;
  }
};


int main()
{
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  string s, t;
  cin >> s;
  cin >> t;
  auto docSize = s.size();
  {
    string tmp = s;
    while (s.size() < tmp.size()*2 + t.size() * 2)
    {
      s += tmp;
    }
  }
  RollingHash sHash(s);
  RollingHash tHash(t);
  UnionFindTree ut(docSize);
  auto hs = tHash.Hash(0, t.size());
  rep(i, docSize){
    if( sHash.Hash(i, i+t.size()) == hs ){
      if(!ut.Connect(i%(docSize), (i+t.size())%(docSize) )){
        printline(-1);
        return 0;
      } 
    }else{
    }
  }
  printline(-(*min_element( all(ut.nodes) )) -1);
}

Measured memory_bytes: 100388