#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
};

int n, m;
vector<int> g[500500];
vector<int> cnt;
vector<bool> seen;
bool flag;

void dfs(int v) {
    if(cnt[v] != -1) return;
    seen[v] = true;
    if(g[v].size()) {
        int u = g[v][0];
        if(cnt[u] == -1) {
            if(seen[u]) { flag = true; return; }
            dfs(u);
            cnt[v] = cnt[u] + 1;
        } else {
            cnt[v] = cnt[u] + 1;
        }
    } else {
        cnt[v] = 0;
    }
    seen[v] = false;
}

void solve() {
	string s, t; cin >> s >> t;
    n = s.size(); m = t.size();
    string ss = s + s;
    for(int i = 0; i <= m / n; ++i) {
        ss += s;
    }
    RollingHash rh(ss);
    RollingHash rht(t);
    LP x = rht.get(0, m);
    rep(i, n) {
        LP y = rh.get(i, i + m);
        if(x == y) {
            int j = (i + m) % n;
            g[j].push_back(i);
        }
    }
    cnt.assign(n, -1);
    seen.assign(n, false);
    flag = false;
    rep(i, n) {
        if(cnt[i] == -1) {
            dfs(i);
        }
    }
    if(flag) {
        cout << -1 << endl;
    } else {
        int res = 0;
        rep(i, n) chmax(res, cnt[i]);
        cout << res << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 134112