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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

template <i64 p>
class fp {
    public:
    i64 x;
    fp() : x(0) {}
    fp(i64 x_) : x((x_ % p + p) % p) {}
    fp operator+() const { return fp(x); }
    fp operator-() const { return fp(-x); }
    fp& operator+=(const fp& y) {
        x += y.x;
        if (x >= p) x -= p;
        return *this;
    }
    fp& operator-=(const fp& y) { return *this += -y; }
    fp& operator*=(const fp& y) {
        x = x * y.x % p;
        return *this;
    }
    fp& operator/=(const fp& y) { return *this *= fp(inverse(y.x)); }
    fp operator+(const fp& y) const { return fp(x) += y; }
    fp operator-(const fp& y) const { return fp(x) -= y; }
    fp operator*(const fp& y) const { return fp(x) *= y; }
    fp operator/(const fp& y) const { return fp(x) /= y; }
    bool operator==(const fp& y) const { return x == y.x; }
    bool operator!=(const fp& y) const { return !(*this == y); }
    i64 extgcd(i64 a, i64 b, i64& x, i64& y) {
        i64 d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    i64 inverse(i64 a) {
        i64 x, y;
        extgcd(a, p, x, y);
        return (x % p + p) % p;
    }
};

template <i64 p>
i64 abs(const fp<p>& x) { return x.x; }

template <i64 p>
ostream& operator<<(ostream& os, const fp<p>& x) {
    os << x.x;
    return os;
}

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "[";
    for (const auto& v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T& val) {
    fill((T*)ary, (T*)(ary + size), val);
}

// x未満の要素の個数を返す
template <typename T>
i64 count_less(const vector<T>& v, T x) {
    return lower_bound(begin(v), end(v), x) - begin(v);
}

// x以下の要素の個数を返す
template <typename T>
i64 count_less_or_equal(const vector<T>& v, T x) {
    return upper_bound(begin(v), end(v), x) - begin(v);
}

// xより大きい要素の個数を返す
template <typename T>
i64 count_greater(const vector<T>& v, T x) {
    return end(v) - upper_bound(begin(v), end(v), x);
}

// x以上の要素の個数を返す
template <typename T>
i64 count_greater_or_equal(const vector<T>& v, T x) {
    return end(v) - lower_bound(begin(v), end(v), x);
}

// x未満の要素のうち最大のものを返す
template <typename T>
T max_less(const vector<T>& v, T x) {
    return *(lower_bound(begin(v), end(v), x) - 1);
}

// x以下の要素のうち最大のものを返す
template <typename T>
T max_less_or_equal(const vector<T>& v, T x) {
    return *(upper_bound(begin(v), end(v), x) - 1);
}

// xより大きい要素のうち最小のものを返す
template <typename T>
T min_greater(const vector<T>& v, T x) {
    return *upper_bound(begin(v), end(v), x);
}

// x以上の要素のうち最小のものを返す
template <typename T>
T min_greater_or_equal(const vector<T>& v, T x) {
    return *lower_bound(begin(v), end(v), x);
}

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr double eps = 1e-9;

struct rolling_hash {
    int mnum;
    std::string str;
    i64 base;
    std::vector<i64> mod;
    std::vector<vector<i64>> hash, pow;

    rolling_hash(const std::string &str, i64 base = 9973, std::vector<i64> mod = {999999937LL, 1000000007LL}) : mnum(mod.size()), str(str), base(base), mod(mod) {
        int size = str.size();
        hash = std::vector<std::vector<i64>>(mnum, std::vector<i64>(size + 1));
        pow = std::vector<std::vector<i64>>(mnum, std::vector<i64>(size + 1));

        for (int i = 0; i < mnum; ++i) {
            hash[i][0] = 0;
            pow[i][0] = 1;
        }
        for (int i = 0; i < mnum; ++i) {
            i64 m = mod[i];
            for (int j = 1; j < size + 1; ++j) {
                pow[i][j] = pow[i][j - 1] * base % m;
                hash[i][j] = (hash[i][j - 1] * base + str[j - 1]) % m;
            }
        }
    }

    i64 compute_hash(int l, int r, int i /* 何番目のmodにおけるハッシュを計算するか */) {  //[l,r)
        return (hash[i][r] - hash[i][l] * pow[i][r - l] % mod[i] + mod[i]) % mod[i];
    }

    bool match(int l, int r, const std::vector<i64> &hs) {
        for (int i = 0; i < mnum; ++i)
            if (compute_hash(l, r, i) != hs[i]) return false;
        return true;
    }
};

class union_find {
private:
    vector<int> parent, rank, gs;
    int size;

public:
    int count_group;
    union_find() = default;
    union_find(int n) { init(n); }

    void init(int n) {
        size = n;
        count_group = n;
        parent.resize(size);
        rank.assign(size, 0);
        gs.assign(size, 1);
        for (int i = 0; i < size; ++i) parent[i] = i;
    }

    int find(int x) {
        if (parent[x] == x)
            return x;
        else
            return parent[x] = find(parent[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            parent[x] = y;
            gs[y] += gs[x];
        } else {
            parent[y] = x;
            gs[x] += gs[y];
            if (rank[x] == rank[y]) ++rank[x];
        }
        --count_group;
    }

    bool is_same_group(int x, int y) {
        return find(x) == find(y);
    }

    int group_size(int x) {
        return gs[find(x)];
    };
};

template <typename T>
pair<vector<T>, map<T, T>> compress(const vector<T>& xs) {
    vector<T> unzip;
    unzip.reserve(xs.size());
    for (const auto& x : xs) unzip.emplace_back(x);

    sort(begin(unzip), end(unzip));
    unzip.erase(unique(begin(unzip), end(unzip)), end(unzip));

    map<T, i64> zip;
    rep(i, 0, unzip.size()) zip[unzip[i]] = i;

    return make_pair(unzip, zip);
}

void solve() {
    //constexpr i64 mod = 998244353;
    string s,t;
    cin >> s >> t;

    {
        string tmp=s;
        while(s.length()<t.length()) s+=tmp;
    }

    rolling_hash sh(s),th(t);

    auto is_ok=[&](i64 si, i64 t_begin, i64 t_end){
        vector<i64> hs;
        rep(i,0,th.mod.size()) hs.emplace_back(th.compute_hash(t_begin, t_end, i));
        return sh.match(si,si+(t_end - t_begin), hs);
    };

    vector<bool> ok(s.length());
    rep(i,0,s.length()){
        if(i+t.length()<=s.length()){
            ok[i]=is_ok(i,0,t.length());
        }else{
            i64 len1=s.length()-i;
            ok[i]=is_ok(i,0,len1) and is_ok(0,len1,t.length());
        }
    }

    union_find uf(s.length());
    rep(i,0,s.length()){
        i64 j=(i+t.length())%s.length();
        uf.unite(i,j);
    }

    unordered_map<i64,vector<i64>> group;
    rep(i,0,s.length()) group[uf.find(i)].emplace_back(i);

    i64 ans=0;
    for(const auto& p:group){
        vector<i64> unzip;
        map<i64,i64> zip;
        tie(unzip,zip)=compress(p.second);

        union_find chain(unzip.size());
        i64 cnt_ok=0;
        rep(i,0,unzip.size()){
            i64 ui=unzip[i];
            i64 uj=(ui+t.length())%s.length();

            assert(zip.find(uj)!=end(zip));
            i64 j=zip[uj];

            if(ok[ui] and ok[uj]) chain.unite(i,j);
            if(ok[ui]) ++cnt_ok;
        }

        if(cnt_ok==unzip.size()){
            cout << -1 << endl;
            return;
        }

        rep(i,0,unzip.size()){
            i64 ui=unzip[i];
            if(!ok[ui]) continue;
            chmax(ans,(i64)chain.group_size(i));
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 208936