#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

typedef pair<ll,ll> Pll;

mt19937 r(std::chrono::high_resolution_clock::now().time_since_epoch().count());
ll mods[] = {999058519, 999125767, 999142337, 999155851, 999191867, 999192457, 999209671, 999232727, 999280361, 999325231, 999336047, 999344851, 999366983, 999389483, 999418463, 999554063, 999557191, 999583111, 999629263, 999645607, 999648743, 999725449, 999811433, 999850463, 999854789, 999964279, 999975107, 999979727, 1000000007, 1000001213, 1000005947, 1000016411, 1000022071, 1000022293, 1000031411, 1000054639, 1000065173, 1000089287, 1000158281, 1000214797, 1000260557, 1000297889, 1000304699, 1000313971, 1000393357, 1000393987, 1000425589, 1000516841, 1000606813, 1000625279, 1000636649, 1000680323, 1000756747, 1000759363, 1000760141, 1000817197, 1000827407, 1000846369, 1000887883, 1000888969, 1000922621, 1000962377, 1000969049, 1000990817};
ll const M = mods[r()&63],base1 = r()%M,base2 = r()%M;

struct RollingHash {
private:
    vector<ll> power1,power2,hash1,hash2;
public:
    RollingHash(string& s) {
        int n = s.size();
        power1.resize(n+1);
        power2.resize(n+1);
        hash1.resize(n+1);
        hash2.resize(n+1);
        power1[0] = power2[0] = 1;
        hash1[0] = hash2[0] = 0;
        for (int i = 0;i < n;++i) power1[i+1] = power1[i]*base1%M;
        for (int i = 0;i < n;++i) power2[i+1] = power2[i]*base2%M;
        for (int i = 0;i < n;++i) hash1[i+1] = (hash1[i]*base1+s[i])%M;
        for (int i = 0;i < n;++i) hash2[i+1] = (hash2[i]*base2+s[i])%M;
    }

    Pll hash(int l, int r)  {
        if (l) return make_pair((hash1[r]+M-hash1[l]*power1[r-l]%M)%M,(hash2[r]+M-hash2[l]*power2[r-l]%M)%M);
        return make_pair(hash1[r],hash2[r]);
    }


    Pll connect(Pll h1,int l,int r) {
        Pll h2 = hash(l,r);
        return make_pair((h1.first*power1[r-l]+h2.first)%M,(h1.second*power2[r-l]+h2.second)%M);
    }

    int LCP(int l1,int r1,RollingHash& rh,int l2,int r2) {
        int ok = 0,ng = min(r1-l1,r2-l2)+1;
        while (ng-ok > 1) {
            int mid = (ok+ng)/2;
            if (hash(l1,l1+mid) == rh.hash(l2,l2+mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
};

int main() {
    string s,t,u;
    cin >> s >> t;
    int n = s.size(),m = t.size(),x,ans = 0;
    u = "";
    for (int i = 0;i < m/n+2;++i) u += s;
    x = u.size();
    RollingHash rht(t),rhu(u);
    vector<int> a(x);
    for (int i = 0;i < n;++i) a[i] = rht.LCP(0,m,rhu,i,x);
    vector<bool> b(n,false),used(n,false);
    for (int i = 0;i < n;++i) {
        if (a[i] < m) continue;
        b[i] = true;
    }
    for (int i = 0;i < n;++i) {
        if (!b[i]) used[i] = true;
        if (b[((i-m)%n+n)%n]) continue;
        int ret = 0,f = i;
        while (b[f]) {
            used[f] = true;
            (f += m) %= n;
            ret++;
        }
        ans = max(ans,ret);
    }
    for (int i = 0;i < n;++i) if (!used[i]) {
        cout << "-1" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 71240