using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC135F
{
    class Program
    {
        static void Main(string[] args)
        {
            var S2 = Console.ReadLine();
            var T = Console.ReadLine();

            //SをTの2倍まで延長
            string S = S2;
            int N = S2.Length;
            StringBuilder sb = new StringBuilder(S);
            sb.Append(S2);
            sb.Append(S2);
            while (sb.Length < T.Length * 2) sb.Append(S2);
            S = sb.ToString();

            //0からmatchを検索
            bool[] match = new bool[S.Length];
            RollingHash rh1 = new RollingHash(S);
            RollingHash rh2 = new RollingHash(T);
            var hash = rh2.Hash();
            for (int i = 0; i < N; i++)
            {
                var hash2 = rh1.Get(i, i + T.Length);
                if (hash[0] == hash2[0] && hash[1] == hash2[1])
                {
                    match[i] = true;
                }
            }

            UnionFind uf = new UnionFind(N);
            for (int i = 0; i < N; i++)
            {
                if (match[i] && match[(i + T.Length) % N])
                {
                    if (!uf.Unite(i, (i + T.Length) % N))
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                }
            }

            int max = 0;
            for (int i = 0; i < N; i++)
            {
                if (match[i])
                {
                    max = Math.Max(uf.Size(i), max);
                }
            }

            Console.WriteLine(max);
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }

    class RollingHash
    {
        const long base1 = 1009;
        const long base2 = 2009;
        const long mod1 = 1000000007;
        const long mod2 = 1000000009;
        long[] hash1, hash2, pow1, pow2;

        public RollingHash(string S)
        {
            int n = S.Length;
            hash1 = new long[n + 1];
            hash2 = new long[n + 1];
            pow1 = new long[n + 1];
            pow2 = new long[n + 1];
            pow1[0] = 1;
            pow2[0] = 1;

            for (int i = 0; i < n; ++i)
            {
                hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
                hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
                pow1[i + 1] = (pow1[i] * base1) % mod1;
                pow2[i + 1] = (pow2[i] * base2) % mod2;
            }
        }

        /**
         * S の [l, r) のハッシュ値を返す
         * O(1)
         */
        public long[] Get(int l, int r)
        {
            long res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
            if (res1 < 0) res1 += mod1;
            long res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
            if (res2 < 0) res2 += mod2;
            return new long[] { res1, res2 };
        }

        /**
         * S のハッシュ値を返す
         * O(1)
         */
        public long[] Hash()
        {
            return Get(0, hash1.Length - 1);
        }

        /**
         * LCP (Longest Common Prefix)
         * O( log N )
         */
        public int GetLCP(int a, int b)
        {
            int len = Math.Min(hash1.Length - a, hash1.Length - b);
            int low = 0, high = len;
            while (high - low > 1)
            {
                int mid = (low + high) >> 1;
                if (Get(a, a + mid) != Get(b, b + mid)) high = mid;
                else low = mid;
            }
            return low;
        }

        /**
         * hash h1 と 長さ h2_len の文字列の hash h2 を結合
         */
        public long[] Concat(long[] h1, long[] h2, int h2_len)
        {
            return new long[] { (h1[0] * pow1[h2_len] + h2[0]) % mod1, (h1[1] * pow2[h2_len] + h2[1]) % mod2 };
        }
    }
}

class UnionFind
{
    int[] par;
    int[] rank;
    int[] count;

    public UnionFind(int n)
    {
        Init(n);
    }

    void Init(int n)
    {
        par = new int[n];
        rank = new int[n];
        count = new int[n].Select(x => 1).ToArray();

        for (int i = 0; i < n; i++)
        {
            par[i] = i;
        }
    }

    public int Find(int x)
    {
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            return par[x] = Find(par[x]);
        }
    }

    public bool Unite(int x, int y)
    {
        x = Find(x);
        y = Find(y);
        if (x == y) return false; //すでに要素を追加済みの場合、falseを返す。

        if (rank[x] < rank[y])
        {
            par[x] = y;
            count[y] += count[x];
        }
        else
        {
            par[y] = x;
            count[x] += count[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
        return true;
    }
    public bool Same(int x, int y)
    {
        return Find(x) == Find(y);
    }

    public int Size(int x)
    {
        return count[Find(x)];
    }
}



Measured memory_bytes: 95484