#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
static constexpr int SZ = 2023456;
int basepow[2][SZ];
struct RollingHash{
    static constexpr int mod = 1e9+7;
    static const int basemod[2];
    vector<int> pre[2];
    const string s;
    const int n;
    void make(){
        rep(i,2){
            basepow[i][0] = 1;
            rep(j,SZ-1){
                basepow[i][j+1] = (long long)basepow[i][j] * basemod[i] % mod;
            }
        }
    }
    RollingHash(const string &_s) : s(_s),n((int)s.size()){
        if(!basepow[0][0])make();
        pre[0].resize(n + 1);
        pre[1].resize(n + 1);
        rep(i,2){
            rep(j,n){
                pre[i][j+1] =((long long)pre[i][j] * basemod[i] % mod + (int)s[j]) % mod;
            }
        }
    }
    // [l,r)
    ll cal_hash(int l, int r){
        ll a = (pre[0][r] - (long long)pre[0][l] * basepow[0][r-l] % mod + mod) % mod;
        ll b = (pre[1][r] - (long long)pre[1][l] * basepow[1][r-l] % mod + mod) % mod;
        return (ll)(a<<30) + b;
    }
    static ll cal(const string &t){
        ll temp[2] = {};
        rep(i,t.size()){
            rep(j,2){
                temp[j] = (temp[j] * basemod[j] + (ll) t[i]) % mod;
            }
        }
        return (ll)(temp[0]<<30) + temp[1];
    }
};
const int RollingHash::basemod[]= {1007, 1000000021};

int main(){
    string a,s,t;
    cin >> a >> t;
    while(s.size() < t.size())s += a;
    s += s;
    RollingHash rh(s);
    ll h = rh.cal(t);
    vector<bool> ok(a.size());
    for(int i = 0; i < s.size() - t.size(); i++){
        ll c = rh.cal_hash(i, i + (int)t.size());
        if(h == c){
            ok[i % a.size()] = true;
        }
    }
    int n = (int) a.size();
    int k = (int) t.size();
    vector<int> dp(n,-1);
    rep(i,n){
        if(dp[i] != -1)continue;
        dp[i] = 0;
        int pos = i;
        if(!ok[pos])continue;
        while(ok[pos]){
            pos += k;
            pos %= n;
            if(pos == i){
                cout << -1 << endl;
                return 0;
            }
            if(!ok[pos]){
                dp[pos] = 0;
                break;
            }
            if(dp[pos] > 0)break;
        }
        while(pos != i){
            pos = pos - k % n + n;
            pos %= n;
            dp[pos] = dp[(pos + k) %n] + 1;
        }
        
    }
    show(dp);
    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 36680