# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html

import sys

def input():

	return sys.stdin.readline()[:-1]



BASE, MOD = 80408696819889532, (1<<61)-1



class RollingHash():

	def __init__(self, s, base, mod):

		self.mod = mod

		self.pw = pw = [1]*(len(s)+1)



		l = len(s)

		self.h = h = [0]*(l+1)



		v = 0

		for i in range(l):

			# case of letters

			h[i+1] = v = (v * base + ord(s[i])) % mod

		v = 1

		for i in range(l):

			pw[i+1] = v = v * base % mod



	# [l. r)

	def get(self, l, r):

		return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod



	def concatenate(self, l1, r1, l2, r2):

		return (self.get(l1, r1) * self.pw[r2-l2] + self.get(l2, r2)) % self.mod



s = eval(input())

s_concat = s

t = eval(input())

ns, nt = len(s), len(t)



if ns == 1:

	if {s} == set(list(t)):

		print((-1))

	else:

		print((0))

	sys.exit()



while len(s_concat) < ns + nt - 1:

	s_concat += s

rh_s, rh_t = RollingHash(s_concat, BASE, MOD), RollingHash(t, BASE, MOD)

t_hash = rh_t.get(0, nt)



adj = [-1 for _ in range(ns)]

for i in range(ns):

	if rh_s.get(i, i+nt) == t_hash:

		if i == (i+nt)%ns:

			print((-1))

			sys.exit()

		adj[i] = (i+nt)%ns



visited = [False for _ in range(ns)]

path_len = [0 for _ in range(ns)]



def dfs(x):

	cur = x

	res = 0

	while adj[cur] >= 0:

		visited[cur] = True

		if adj[cur] == x:

			print((-1))

			sys.exit()

		res += 1

		if path_len[adj[cur]] > 0:

			path_len[x] = path_len[adj[cur]] + res

			return path_len[adj[cur]] + res

		cur = adj[cur]

	path_len[x] = res

	return res



ans = 0

for i in range(ns):

	if not visited[i]:

		d = dfs(i)

		ans = max(ans, d)



if ans == ns:

	print((-1))

else:

	print(ans)
import sys

def input():

	return sys.stdin.readline()[:-1]



class KMP():

	def __init__(self, sentence):

		self.sentence = sent = sentence

		self.l = l = len(sent)

		self.table = table = [0 for _ in range(l+1)]

		table[0] = -1

		j = -1

		for i in range(l):

			while j >= 0 and sent[i] != sent[j]:

				j = table[j]

			j += 1

			if i < l-1 and sent[i+1] == sent[j]:

				table[i+1] = table[j]

			else:

				table[i+1] = j



	def search(self, key):

		table = self.table

		sent = self.sentence

		l = self.l

		i = 0

		res = []

		for j in range(len(key)):

			while i > -1 and sent[i] != key[j]:

				i = table[i]

			i += 1

			if i >= l:

				res.append(j-i+1)

				i = table[i]

		return res





s = eval(input())

s_concat = s

t = eval(input())

ns, nt = len(s), len(t)



if ns == 1:

	if {s} == set(list(t)):

		print((-1))

	else:

		print((0))

	sys.exit()



while len(s_concat) < ns + nt - 1:

	s_concat += s



adj = [-1 for _ in range(ns)]



kmp = KMP(t)

matches = kmp.search(s_concat)



for i in matches:

	if i >= ns:

		break

	if i == (i+nt)%ns:

		print((-1))

		sys.exit()

	adj[i] = (i+nt)%ns





visited = [False for _ in range(ns)]

path_len = [0 for _ in range(ns)]



def dfs(x):

	cur = x

	res = 0

	while adj[cur] >= 0:

		visited[cur] = True

		if adj[cur] == x:

			print((-1))

			sys.exit()

		res += 1

		if path_len[adj[cur]] > 0:

			path_len[x] = path_len[adj[cur]] + res

			return path_len[adj[cur]] + res

		cur = adj[cur]

	path_len[x] = res

	return res



ans = 0

for i in range(ns):

	if not visited[i]:

		d = dfs(i)

		ans = max(ans, d)



if ans == ns:

	print((-1))

else:

	print(ans)
# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
import sys


def input():
    return sys.stdin.readline()[:-1]


BASE, MOD = 80408696819889532, (1 << 61) - 1


class RollingHash:
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1] * (len(s) + 1)
        l = len(s)
        self.h = h = [0] * (l + 1)
        v = 0
        for i in range(l):
            # case of letters
            h[i + 1] = v = (v * base + ord(s[i])) % mod
        v = 1
        for i in range(l):
            pw[i + 1] = v = v * base % mod

    # [l. r)
    def get(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r - l]) % self.mod

    def concatenate(self, l1, r1, l2, r2):
        return (self.get(l1, r1) * self.pw[r2 - l2] + self.get(l2, r2)) % self.mod


s = eval(input())
s_concat = s
t = eval(input())
ns, nt = len(s), len(t)
if ns == 1:
    if {s} == set(list(t)):
        print((-1))
    else:
        print((0))
    sys.exit()
while len(s_concat) < ns + nt - 1:
    s_concat += s
rh_s, rh_t = RollingHash(s_concat, BASE, MOD), RollingHash(t, BASE, MOD)
t_hash = rh_t.get(0, nt)
adj = [-1 for _ in range(ns)]
for i in range(ns):
    if rh_s.get(i, i + nt) == t_hash:
        if i == (i + nt) % ns:
            print((-1))
            sys.exit()
        adj[i] = (i + nt) % ns
visited = [False for _ in range(ns)]
path_len = [0 for _ in range(ns)]


def dfs(x):
    cur = x
    res = 0
    while adj[cur] >= 0:
        visited[cur] = True
        if adj[cur] == x:
            print((-1))
            sys.exit()
        res += 1
        if path_len[adj[cur]] > 0:
            path_len[x] = path_len[adj[cur]] + res
            return path_len[adj[cur]] + res
        cur = adj[cur]
    path_len[x] = res
    return res


ans = 0
for i in range(ns):
    if not visited[i]:
        d = dfs(i)
        ans = max(ans, d)
if ans == ns:
    print((-1))
else:
    print(ans)

import sys


def input():
    return sys.stdin.readline()[:-1]


class KMP:
    def __init__(self, sentence):
        self.sentence = sent = sentence
        self.l = l = len(sent)
        self.table = table = [0 for _ in range(l + 1)]
        table[0] = -1
        j = -1
        for i in range(l):
            while j >= 0 and sent[i] != sent[j]:
                j = table[j]
            j += 1
            if i < l - 1 and sent[i + 1] == sent[j]:
                table[i + 1] = table[j]
            else:
                table[i + 1] = j

    def search(self, key):
        table = self.table
        sent = self.sentence
        l = self.l
        i = 0
        res = []
        for j in range(len(key)):
            while i > -1 and sent[i] != key[j]:
                i = table[i]
            i += 1
            if i >= l:
                res.append(j - i + 1)
                i = table[i]
        return res


s = eval(input())
s_concat = s
t = eval(input())
ns, nt = len(s), len(t)
if ns == 1:
    if {s} == set(list(t)):
        print((-1))
    else:
        print((0))
    sys.exit()
while len(s_concat) < ns + nt - 1:
    s_concat += s
adj = [-1 for _ in range(ns)]
kmp = KMP(t)
matches = kmp.search(s_concat)
for i in matches:
    if i >= ns:
        break
    if i == (i + nt) % ns:
        print((-1))
        sys.exit()
    adj[i] = (i + nt) % ns
visited = [False for _ in range(ns)]
path_len = [0 for _ in range(ns)]


def dfs(x):
    cur = x
    res = 0
    while adj[cur] >= 0:
        visited[cur] = True
        if adj[cur] == x:
            print((-1))
            sys.exit()
        res += 1
        if path_len[adj[cur]] > 0:
            path_len[x] = path_len[adj[cur]] + res
            return path_len[adj[cur]] + res
        cur = adj[cur]
    path_len[x] = res
    return res


ans = 0
for i in range(ns):
    if not visited[i]:
        d = dfs(i)
        ans = max(ans, d)
if ans == ns:
    print((-1))
else:
    print(ans)

-# https://tjkendev.github.io/procon-library/python/string/rolling_hash.html -BASE, MOD = 80408696819889532, (1 << 61) - 1 +class KMP: +    def __init__(self, sentence): +        self.sentence = sent = sentence +        self.l = l = len(sent) +        self.table = table = [0 for _ in range(l + 1)] +        table[0] = -1 +        j = -1 +        for i in range(l): +            while j >= 0 and sent[i] != sent[j]: +                j = table[j] +            j += 1 +            if i < l - 1 and sent[i + 1] == sent[j]: +                table[i + 1] = table[j] +            else: +                table[i + 1] = j - -class RollingHash: -    def __init__(self, s, base, mod): -        self.mod = mod -        self.pw = pw = [1] * (len(s) + 1) -        l = len(s) -        self.h = h = [0] * (l + 1) -        v = 0 -        for i in range(l): -            # case of letters -            h[i + 1] = v = (v * base + ord(s[i])) % mod -        v = 1 -        for i in range(l): -            pw[i + 1] = v = v * base % mod - -    # [l. r) -    def get(self, l, r): -        return (self.h[r] - self.h[l] * self.pw[r - l]) % self.mod - -    def concatenate(self, l1, r1, l2, r2): -        return (self.get(l1, r1) * self.pw[r2 - l2] + self.get(l2, r2)) % self.mod +    def search(self, key): +        table = self.table +        sent = self.sentence +        l = self.l +        i = 0 +        res = [] +        for j in range(len(key)): +            while i > -1 and sent[i] != key[j]: +                i = table[i] +            i += 1 +            if i >= l: +                res.append(j - i + 1) +                i = table[i] +        return res -rh_s, rh_t = RollingHash(s_concat, BASE, MOD), RollingHash(t, BASE, MOD) -t_hash = rh_t.get(0, nt) -for i in range(ns): -    if rh_s.get(i, i + nt) == t_hash: -        if i == (i + nt) % ns: -            print((-1)) -            sys.exit() -        adj[i] = (i + nt) % ns +kmp = KMP(t) +matches = kmp.search(s_concat) +for i in matches: +    if i >= ns: +        break +    if i == (i + nt) % ns: +        print((-1)) +        sys.exit() +    adj[i] = (i + nt) % ns