import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    immutable int INF = 10 ^^ 9 + 7;
    
    auto s = readln.chomp;
    auto t = readln.chomp;
    
    auto need = (s.length + t.length - 1 + s.length - 1) / s.length;
    
    debug { need.writeln; }
    
    
    auto strBuilder = appender!string;
    foreach (i; 0 .. need) { strBuilder.put(s); }

    string multis = strBuilder.data;
    
    //auto multis = s.repeat(need).joiner.to!string;
    
    debug { multis.writeln; }
    
    auto bmFinder = boyerMooreFinder(t);
    auto ok = new bool[multis.length];
    string ns = multis;
    auto cut = 0;
    while (!(ns = bmFinder.beFound(multis[cut .. $])).empty()) {
        cut = (multis.length - ns.length).to!int;
        ok[cut] = true;
        
        ++cut;
    }
    
    debug { ok.writeln; }
    
    auto ans = new int[s.length];
    auto vis = new int[s.length];
    foreach (i; 0 .. s.length) {
        if (vis[i] == 2) { continue; }
        
        int go(ulong p) {
            if (vis[p] == 2) { return ans[p]; }
            if (vis[p] == 1) { return INF; }
            
            vis[p] = 1;
            
            ans[p] = 0;
            if (ok[p]) {
                ans[p] = 1 + go((p + t.length) % s.length);
            }
            
            vis[p] = 2;
            return ans[p];
        }
        
        ans[i] = go(i);
    }
    
    debug { ans.writeln; }
    
    int mx = 0;
    foreach (e; ans) { mx = max(mx, e); }
    
    if (mx >= INF) { mx = -1; }
    
    mx.writeln;
}