using System;
using System.Linq;
using System.Text;
using CompLib.Mathematics;
using CompLib.Util;

public class Program
{
    private string S;
    private string T;

    private const long P1 = 1000000007;
    private const long P2 = 998244353;

    public void Solve()
    {
        var sc = new Scanner();
        S = sc.Next();
        T = sc.Next();

        // ローリングハッシュ
        long hashT1 = 0;
        long hashT2 = 0;
        for (int i = 0; i < T.Length; i++)
        {
            hashT1 *= 26;
            hashT1 += T[i] - 'a';
            hashT1 %= P1;

            hashT2 *= 26;
            hashT2 += T[i] - 'a';
            hashT2 %= P2;
        }

        long[] hashS1 = new long[S.Length];
        long[] hashS2 = new long[S.Length];


        // 26^|T|
        long m1 = 1;
        long m2 = 1;

        for (int i = 0; i < T.Length; i++)
        {
            hashS1[0] *= 26;
            hashS1[0] += S[i % S.Length] - 'a';
            hashS1[0] %= P1;
            m1 *= 26;
            m1 %= P1;

            hashS2[0] *= 26;
            hashS2[0] += S[i % S.Length] - 'a';
            hashS2[0] %= P2;

            m2 *= 26;
            m2 %= P2;
        }


        for (int i = 0; i < S.Length - 1; i++)
        {
            hashS1[i + 1] = hashS1[i] * 26;
            hashS1[i + 1] += S[(i + T.Length) % S.Length] - 'a';
            hashS1[i + 1] -= (S[i] - 'a') * m1;
            hashS1[i + 1] %= P1;
            if (hashS1[i + 1] < 0) hashS1[i + 1] += P1;

            hashS2[i + 1] = hashS2[i] * 26;
            hashS2[i + 1] += S[(i + T.Length) % S.Length] - 'a';
            hashS2[i + 1] -= (S[i] - 'a') * m2;
            hashS2[i + 1] %= P2;
            if (hashS2[i + 1] < 0) hashS2[i + 1] += P2;
        }

        bool[] f = new bool[S.Length];
        for (int i = 0; i < S.Length; i++)
        {
            f[i] = hashS1[i] == hashT1 && hashS2[i] == hashT2;
        }

        // f_b, f_{b+|t|} ... f_{b+(i-1)|t|}がtrue

        // 一致する位置が無い
        if (!f.Any(b => b))
        {
            Console.WriteLine("0");
            return;
        }

        long gcd = MathEx.GCD(S.Length, T.Length);
        bool[] a = new bool[gcd];
        for (int i = 0; i < S.Length; i++)
        {
            if (!f[i]) a[i % gcd] = true;
        }

        if (a.Any(b => !b))
        {
            Console.WriteLine("-1");
            return;
        }
        
        long ans = long.MinValue;
        for (int b = 0; b < S.Length; b++)
        {
            // 前は一致しない
            int prev = (b - T.Length) % S.Length;
            if (prev < 0) prev += S.Length;
            if (f[prev]) continue;

            int cur = b;
            long cnt = 0;
            while (f[cur])
            {
                cnt++;
                cur += T.Length;
                cur %= S.Length;
            }

            ans = Math.Max(ans, cnt);
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System;
    using System.Collections.Generic;

    #region GCD LCM

    /// <summary>
    /// 様々な数学的関数の静的メソッドを提供します．
    /// </summary>
    public static partial class MathEx
    {
        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static int GCD(int n, int m)
        {
            return (int) GCD((long) n, m);
        }


        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static long GCD(long n, long m)
        {
            n = Math.Abs(n);
            m = Math.Abs(m);
            while (n != 0)
            {
                m %= n;
                if (m == 0) return n;
                n %= m;
            }

            return m;
        }


        /// <summary>
        /// 2 つの整数の最小公倍数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最小公倍数</returns>
        /// <remarks>最悪計算量 O(log N) で実行されます．</remarks>
        public static long LCM(long n, long m)
        {
            return (n / GCD(n, m)) * m;
        }
    }

    #endregion

    #region PrimeSieve

    public static partial class MathEx
    {
        /// <summary>
        /// ある値までに素数表を構築します．
        /// </summary>
        /// <param name="max">最大の値</param>
        /// <param name="primes">素数のみを入れた数列が返される</param>
        /// <returns>0 から max までの素数表</returns>
        /// <remarks>エラトステネスの篩に基づき，最悪計算量 O(N loglog N) で実行されます．</remarks>
        public static bool[] Sieve(int max, List<int> primes = null)
        {
            var isPrime = new bool[max + 1];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i * i <= max; i++)
                if (!isPrime[i]) continue;
                else
                    for (int j = i * i; j <= max; j += i)
                        isPrime[j] = false;
            if (primes != null)
                for (int i = 0; i <= max; i++)
                    if (isPrime[i])
                        primes.Add(i);

            return isPrime;
        }
    }

    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 38948