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

int dp[500000*2];

// Fills Z array for given string str[] 
void getZarr(string str, int Z[]) 
{ 
    int n = str.length(); 
    int L, R, k; 
  
    // [L,R] make a window which matches with prefix of s 
    L = R = 0; 
    for (int i = 1; i < n; ++i) 
    { 
        // if i>R nothing matches so we will calculate. 
        // Z[i] using naive way. 
        if (i > R) 
        { 
            L = R = i; 
  
            // R-L = 0 in starting, so it will start 
            // checking from 0'th index. For example, 
            // for "ababab" and i = 1, the value of R 
            // remains 0 and Z[i] becomes 0. For string 
            // "aaaaaa" and i = 1, Z[i] and R become 5 
            while (R<n && str[R-L] == str[R]) 
                R++; 
            Z[i] = R-L; 
            R--; 
        } 
        else
        { 
            // k = i-L so k corresponds to number which 
            // matches in [L,R] interval. 
            k = i-L; 
  
            // if Z[k] is less than remaining interval 
            // then Z[i] will be equal to Z[k]. 
            // For example, str = "ababab", i = 3, R = 5 
            // and L = 2 
            if (Z[k] < R-i+1) 
                Z[i] = Z[k]; 
  
            // For example str = "aaaaaa" and i = 2, R is 5, 
            // L is 0 
            else
            { 
                // else start from R and check manually 
                L = i; 
                while (R<n && str[R-L] == str[R]) 
                    R++; 
                Z[i] = R-L; 
                R--; 
            } 
        } 
    } 
}

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color) {
  color[v] = 1;
  FOR(e, g[v]) {
    if (color[e->dst] == 2) continue;
    if (color[e->dst] == 1) return false;
    if (!visit(g, e->dst, order, color)) return false;
  }
  order.push_back(v); color[v] = 2;
  return true;
}
bool topologicalSort(const Graph &g, vector<int> &order) {
  int n = g.size();
  vector<int> color(n);
  REP(u, n) if (!color[u] && !visit(g, u, order, color))
    return false;
  reverse(ALL(order));
  return true;
}

int main()
{
	string S, T;
	cin >> S >> T;

	string s = S;
	while( S.length() < T.length() ) {
		S += s;
	}
	int sn = S.length();
	int tn = T.length();
	string concat = T + '$' + S + S;
	int l = concat.length();
	int Z[l];
	getZarr( concat, Z );
	Graph g( sn );
	for( int i = tn + 1; i < sn + tn + 1; i++ ) {
		if( Z[i] == tn ) {
			int n = i - (tn + 1);
			g[n].push_back( Edge( 0, (n + tn) % sn, 1 ) );
		}
	}
	vector<int> order;
	bool res = topologicalSort( g, order );
	if( res == false ) {
		cout << -1 << endl;
	}
	else {
		int ans = 0;
		for( auto cu : order ) {
			ans = max( ans, dp[cu] );
			for( auto to : g[cu] ) {
				dp[to.dst] = max( dp[to.dst], dp[cu] + 1 );
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 104532