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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll MS = 1;
const ll mods[] = {1000000007ll}, base = 9973;
//const ll mods[] = {999999937ll, 1000000007ll}, base = 9973;
struct rolling_hash {
    int n;
    vector<ll> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mods[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mods[i];
            }
        }
    }

    // hash number of segment [l, r)
    ll hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mods[i]+mods[i])%mods[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, ll h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

/*
ll count(string& X, string& Y){
	rolling_hash rx(X), ry(Y);
	ll cnt = 0;
	ll N = Y.size();
	ll ha[2] = {ry.hash(0, N, 0), ry.hash(0, N, 1)};
	REP(i, X.size()){
		ll j = i;
		ll tmp = 0;
		while(j+N<=X.size() && rx.match(j, j+N, ha)){
			j += N;
			tmp++;
		}
		//printf("%lld %lld\n", i, j);
		cnt = max(cnt, tmp);
		if(i==j) i = j;
		else i = j-1;
	}
	return cnt;
}
*/


ll count(string& X, string& Y){
	rolling_hash rx(X);
	ll N = Y.size();
	ll lb = -1;
	ll ub = 1501010;
	while(ub-lb>1){
		ll m = (lb+ub)/2;
		bool flag = false;
		if(X.size() >= m*N){
			string Z = "";
			REP(i, m) Z += Y;
			rolling_hash rz(Z);
			//dump(Z)
			//ll ha[2] = {rz.hash(0, m*N, 0), rz.hash(0, m*N, 1)};
			ll ha[1] = {rz.hash(0, m*N, 0)};
			REP(i, X.size()){
				if(i+m*N>X.size()) break;
				if(rx.match(i, i+m*N, ha)) flag = true;
			}
		}
		if(flag) lb = m;
		else ub = m;
	}
	return ub-1;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S, t;
    cin >> S >> t;
    string s = "";
    while(s.size() < t.size()){
    	s += S;
    }
    
    string p = s+s+s;
    string q = p+p;
    ll cnt1 = count(p, t);
    ll cnt2 = count(q, t);
    //dump(cnt1)
    //dump(cnt2)
    cout << (cnt1 == cnt2 ? cnt1 : -1) << endl;

    return 0;
}

Measured memory_bytes: 207480