#include <cstdio>
#include <cstring>
#include <cassert>
#include <set>
#include <algorithm>

char s[500010], t[1000010];
int fail[500010], cnt[500010], ans;
bool exist[500010];

bool init_fail_array(char s[], int len, int _k) {
    fail[0] = -1;
    for(int i = 1, k = -1; s[i]; ++i) {
        while(~k && s[i] != s[k+1]) k = fail[k];
        if(s[i] == s[k+1])  fail[i] = ++k;
        else                fail[i] = -1;
    }
    int f = fail[len-1];
    while(~f && f != _k-1)    f = fail[f];
    if(f == _k-1)   return true;
    else            return false;
    // memset(exist, -1, sizeof(exist));
    // int f = fail[len-1], i = len-2;
    // while(~f) {
    //     while(i > f)    exist[i%_k] = false;
    //     f = fail[f];
    // }
}

void kmp(char s[], char t[], int n, int m) {
    // std::set<int> st;
    for(int i = 0, k = -1; t[i]; ++i) {
        while(~k && s[k+1] != t[i]) k = fail[k];
        if(s[k+1] == t[i])  ++k;
        if(!s[k+1]) {
            k = fail[k];
            // st.insert(i);
            cnt[i+1] = cnt[i-n+1] + 1;
            ans = std::max(cnt[i+1], ans);
        }
    }
    // return st;
}

int main() {
    scanf("%s%s", t, s);
    int n = strlen(s), m = strlen(t), k = m%n;
    int _m = (n/m)*m;
    if(_m < n)  _m += m;
    if(_m == m) _m += m;
    // for(int i = m; i < m+n-1; ++i)    t[i] = t[i-m];
    for(int i = m; i < _m; ++i) t[i] = t[i%m];
    t[_m] = '\0';
    bool infinity = init_fail_array(s, n, k);
    kmp(s, t, n, _m);
    for(int i = _m; i >= m; --i) {
        if(cnt[i] >= (m+n-1)/n) {
            if(infinity)  { printf("-1");  return 0; }
        }
    }
    printf("%d", ans);
    return 0;
}