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 dfs1(node):
        if visited[node] == 1:
            return True
        if visited[node] == 2:
            return False
        visited[node] = 1
        for nei in edges[node]:
            if dfs1(nei):
                return True
        visited[node] = 2
        return False
    visited = [-1] * n
    for i in range(n):
        if dfs1(i):
            return -1
    
    
    
    def dfs(node, adj, dp, vis):  
        
        vis[node] = True  
        for i in range(0, len(adj[node])):   
            if not vis[adj[node][i]]: 
                dfs(adj[node][i], adj, dp, vis)   
            dp[node] = max(dp[node], 1 + dp[adj[node][i]])   
         
    def findLongestPath(adj, n):  
    
        dp = [0] * n 
          
        vis = [False] * n
     
        for i in range(n):   
            if not vis[i]:  
                dfs(i, adj, dp, vis) 
                
        ans = 0 
        for i in range(n):   
            ans = max(ans, dp[i])  
           
        return ans
    
    ans = findLongestPath(edges, n)
    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())


### 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())