class Solution():
    def stringOfEternity(self, S, T):
        m, n = len(S), len(T)
        def getFail():
            i, j = 0, -1
            f[i] = j
            # prepare roll-back table
            while i < len(T):
                # roll-back
                while j >= 0 and T[i] != T[j]: j = f[j]
                i, j = i + 1, j + 1
                f[i] = j
                
        def KMP():
            j = 0
            for i in range(m):
                while j and S[i] != T[j]:
                    j = f[j]
                if S[i] == T[j]:
                    j = j + 1
                else:
                    j = 0
                if j == n:
                    sign[i-n+1] = 1
                    j = f[j]
#                   
      
        def dfs(node):
            if visited[node] == 1:
                return False
            if visited[node] == 2:
                return True
            
            visited[node] = 1
            
            for nei in graph[node]:
                if not dfs(nei): return False
            visited[node] = 2
            q[self.count] = node
            self.count += 1
            return True
        
        f = [0] * (n+1)
        getFail()

        sign = [0] * (m+1)
        KMP()
        
        #print sign
        graph = [[] for _ in range(m+1)]
        for i in range(len(S)):
            j = (i+n) % len(s)
            if sign[i]:
                graph[i].append(j)
        #print graph
                
        visited = [-1] * (1+m)
        q = [0] *(1+m)
        
        self.count = 0
        for i in range(m):
            if not dfs(i):
                return -1
         
        assert self.count == m
        dp = [0] * (1+m)
        ans = 0
        for i in range(m, -1, -1):
            t = q[i]
            for c in graph[t]:
                dp[c] = max(dp[c], dp[t] + 1)
                ans = max(ans, dp[c])
        return ans

s = input()
t = input()


n_, m_ = len(s), len(t)
nn = n_
S = s
while n_ < nn + m_:
    for i in range(nn):
        S += s[i]
        n_ += 1
S +='#'
T = t
print Solution().stringOfEternity(S, T)

### FIXED CODE ###

class KMP():
    def __init__(self, pattern):
        self.pattern = pattern
        self.n = len(pattern)
        self.create_k_table()
    
    def create_k_table(self):
        ktable = [-1]*(self.n+1)
        j = -1
        for i in range(self.n):
            while j >= 0 and self.pattern[i] != self.pattern[j]:
                j = ktable[j]
            j += 1
            if i+1 < self.n and self.pattern[i+1] == self.pattern[j]:
                ktable[i+1] = ktable[j]
            else:
                ktable[i+1] = j
        self.ktable = ktable

    def match(self,s):
        n = len(s)
        j = 0
        ret = [0]*n
        for i in range(n):
            while j >= 0 and (j == self.n or s[i] != self.pattern[j]):
                j = self.ktable[j]
            j += 1
            if j == self.n:
                ret[(i-self.n+1)%n] = 1 
        return ret

def main():
    s = input()
    t = input()
    n = len(s)
    m = len(t)
    k = 1 - (-(m-1)//n)
    si = s*k
    a = KMP(t)
    b = a.match(si)
#    edges = [[] for i in range(n)]
#    for i in range(n):
#        if b[i]:
#            edges[i].append((i+m)%n)
#    
#    def dfs(node):
#        if visited[node] == 1:
#            return True
#        if visited[node] == 2:
#            return False
#        visited[node] = 1
#        for nei in edges[node]:
#            if dfs(nei):
#                return True
#        visited[node] = 2
#        res.append(node)
#        return False
#    visited = [-1] * n
#    res = []
#    for i in range(n):
#        if dfs(i):
#            return -1
#    dp = [0] * n
#    ans = 0
#    for i in range(n-1, -1, -1):
#        t = res[i]
#        for c in edges[t]:
#            dp[c] = max(dp[c], dp[t] + 1)
#            ans = max(ans, dp[c])
#    return ans

            
    visited = [0]*n
    loop = False
    ans = 0
    for i in range(n):
        if visited[i]:
            continue
        visited[i] = 1
        cur = i
        right = 0
        while b[cur]:
            nxt = (cur + m) % n
            if visited[nxt]:
                loop = True
                break
            visited[nxt] = 1
            cur = nxt
            right += 1
        cur = i
        left = 0
        while b[(cur-m)%n]:
            nxt = (cur-m) % n
            if visited[nxt]:
                loop = True
                break
            visited[nxt] = 1
            cur = nxt
            left += 1
        if not loop:
            ans = max(ans, right+left)
        else:
            ans = -1
            break
    return ans

if __name__ == "__main__":
    print(main())