// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// Rolling Hash
// Verified: AOJ 2444 (Substring)

struct RollingHash {
public:
    long long base_1, base_2, mod_1, mod_2;
    vector<long long> hash1, hash2, pow1, pow2;

    // init (constructor)
    RollingHash(string s) : base_1(1013), base_2(1007),
        mod_1(1000000007), mod_2(1000000009),
        hash1(s.length()+1,0), hash2(s.length()+1,0),
        pow1(s.length()+1,1), pow2(s.length()+1,1) {
            for(int i=0; i<s.length(); i++) {
                hash1[i+1] = (hash1[i]+s[i]) * base_1 % mod_1;
                hash2[i+1] = (hash2[i]+s[i]) * base_2 % mod_2;
                pow1[i+1] = pow1[i] * base_1 % mod_1;
                pow2[i+1] = pow2[i] * base_2 % mod_2;
            }
        }

    // calc str[l,r) hash (0-indexed)
    // if get(i1,j1) == get(i2,j2) -> identical string
    pair<long long, long long> get(int l, int r) {
        long long t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod_1 + mod_1) % mod_1;
        long long t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod_2 + mod_2) % mod_2;
        return make_pair(t1, t2);
    }
};

int main() {
    string s, t, pat; cin >> s >> t; pat = s;
    int N = s.size(), M = t.size();
    int L = N + M - 1;
    while(s.size() < L) s += pat;

    RollingHash hash_s(s), hash_t(t);
    vector<int> fwd(N, -1), indeg(N);
    for(int i=0; i<N; i++) {
        if(hash_s.get(i, i+M) == hash_t.get(0, M)) {
            fwd[i] = (i + M) % N;
            indeg[(i + M) % N]++;
        }
    }

    bool exist_loop = false;
    int ans = 0;

    // 閉路検出
    vector<int> checked(N);
    for(int i=0; i<N; i++) {
        if(fwd[i] < 0 or checked[i]) continue;
        int pos = i;
        while(true) {
            checked[pos] = true;
            pos = fwd[pos];
            if(pos == i) {
                exist_loop = true;
                break;
            }
            else if(pos < 0) {
                break;
            }
        }
    }

    if(exist_loop) {
        cout << -1 << endl;
        return 0;
    }

    // 答え
    for(int i=0; i<N; i++) {
        if(fwd[i] < 0 or indeg[i] > 0) continue;
        int pos = i, cnt = 0;
        while(true) {
            // fprintf(stderr, "pos = %d\n", pos);
            pos = fwd[pos];
            if(pos < 0) break;
            cnt++;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 71544