#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        hash3.assign(n+1, 0);

        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        power3.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;
            hash3[i+1] = (hash3[i] * base3 + S[i]) % mod3;

            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
            power3[i+1] = (power3[i] * base3) % mod3;

        }
    }

    // get hash of S[left:right]
    //inline pair<long long, long long> get(int l, int r) const {
    inline tuple<long long, 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;
        long long res3 = hash3[r] - hash3[l] * power3[r-l] % mod3;
        if (res3 < 0) res3 += mod3;

        return make_tuple(res1, res2, res3);
    }
};

struct TopologicalSort{
    vector<vector<int>> E;
    TopologicalSort(int N){ E.resize(N);}
    void add_edge(int a, int b) {E[a].push_back(b);}
    bool visit(int v, vector<int> &order, vector<int> &color){
        color[v] = 1;
        for(int u : E[v]){
            if(color[u] == 2) continue;
            if(color[u] == 1) return false;

            if(!visit(u,order,color)) return false;
        }
        order.push_back(v);
        color[v] = 2;
        return true;
    }
    bool sort(vector<int> &order){
        int n = E.size();
        vector<int> color(n);
        for(int u = 0; u < n; u++){
            if(!color[u] && !visit(u,order,color)) return false;
        }
        reverse(order.begin(),order.end());
        return true;
    }
};

int dp[5123456] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    string tS = S;
    int slen = S.length();
    int tlen = T.length();

    while(tS.length() < 3*T.length()) tS += S;
    
    tS += S;

    RollingHash sh(tS);
    RollingHash th(T);

    VI match(slen);
    REP(i,slen){
        if(sh.get(i,i+tlen) == th.get(0,tlen)) match[i] = 1;
    }
    TopologicalSort toposo(slen);
    REP(i,slen){
        if(match[i]){
            //dump(i)
            toposo.add_edge(i,(i+tlen)%slen);
            //cerr << "add "<< i << " " << (i+tlen)%slen << endl;
        }
    }
    VI ord;
    bool res = toposo.sort(ord);
    if(res == false){
        cout << -1 << endl;
    }else{
        int ans = 0;
        for(int cu : ord){
            ans = max(ans,dp[cu]);
            for(int to : toposo.E[cu]){
                dp[to] = max(dp[to], dp[cu]+1);
            }
        }
        cout << ans << endl;

    }





}


Measured memory_bytes: 187872