/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 3e6 + 5;

int n, m, l, ans = 0;
int z[maxn], g[maxn], deg[maxn], q[maxn], dp[maxn];
char s[maxn], t[maxn], str[maxn];

void zAlgo(){
	int lb = -1, rb = -1;
	z[0] = l;
	FOR(i, 1, l){
		if(i <= rb) z[i] = min(rb - i + 1, z[i - lb]);
		//printf("z = %d\n", z[i]);
		for(int &j = z[i]; i + j < l && str[j] == str[i + j]; ++j) /*printf("i = %d j = %d %c %c\n", i, j, str[i], str[i + j])*/;
		if(i + z[i] - 1 > rb) lb = i, rb = i + z[i] - 1;
	}
	return;
}

bool topoSort(){
	int hd = 0, tl = 0, ret = 0;
	FOR(i, 0, m) if(!deg[i]) q[tl++] = i;
	for(; hd < tl; ++hd){
		int u = q[hd];
		//printf("u = %d\n", u);
		++ret;
		if(g[u] && !(--deg[(u + n) % m])){
			//printf("v = %d\n", (u + n) % m);
			q[tl++] = (u + n) % m;
		}
	}
	return (ret == m);
}

int main(){
	scanf("%s%s", t, s);
	n = strlen(s); m = strlen(t);
	for(l = 0; l < n; ++l) str[l] = s[l];
	for(; l - n < n;){
		for(int i = 0; i < m; ++i) str[l++] = t[i];
	}
	for(int i = n, j = l; i < j; ++i){
		//printf("%d %d\n", l + i - n, i);
		str[l + i - n] = str[i];
	}
	l = l * 2 - n;
	//puts(str);
	zAlgo();
	//FOR(i, 0, l) printf("%d ", z[i]);
	//puts("");
	FOR(i, n, n + m) if(z[i] >= n){
		//printf("i = %d\n", i);
		g[i - n] = true;
		++deg[i % m];
	}
	if(!topoSort()){
		puts("-1");
		return 0;
	}
	else{
		for(int i = m - 1; i >= 0; --i){
			//printf("(%d %d)\n", q[i], q[i] + n);
			if(g[q[i]]) dp[q[i]] = dp[(q[i] + n) % m] + 1;
			else dp[q[i]] = 0;
			ans = max(dp[q[i]], ans);
			//printf("%d ", dp[q[i]]);
		}
		//puts("");
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 33024