maxN = 10**6+10
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] * maxN
        getFail()

        sign = [0] * maxN
        KMP()
        
        graph = [[] for _ in range(maxN)]
        for i in range(len(S)):
            j = (i+n) % (m-1)
            if sign[i]:
                graph[i].append(j)
        print graph
                
        visited = [-1] * maxN
        q = [0] * maxN
        
        self.count = 0
        for i in range(m):
            if not dfs(i):
                return -1
         
        assert self.count == m
        dp = [0] * maxN
        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())