use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let t: String = input();

    let slen = s.len();
    let tlen = t.len();

    let rt = RollingHashString::from_str(&t);
    let mut rs = RollingHashString::new();
    while rs.len() < slen + tlen {
        rs.push_str(&s);
    }

    let mut succ = vec![slen; slen];
    let mut pred = vec![0; slen];
    for i in 0..slen {
        if rs.substr(i, tlen) == rt {
            let j = (i + tlen) % slen;
            succ[i] = j;
            pred[j] += 1;
        }
    }

    let mut dist = vec![-1; slen];
    let mut q = std::collections::VecDeque::new();
    for i in 0..slen {
        if pred[i] == 0 {
            dist[i] = 0;
            q.push_back(i);
        }
    }
    while let Some(i) = q.pop_front() {
        if succ[i] == slen {
            continue;
        }
        let j = succ[i];
        pred[j] -= 1;
        dist[j] = dist[i] + 1;
        if pred[j] == 0 {
            q.push_back(j);
        }
    }

    let mut ok = true;
    let mut ans = 0;
    for i in 0..slen {
        if dist[i] < 0 {
            ok = false;
            break;
        }
        ans = std::cmp::max(ans, dist[i]);
    }

    println!("{}", if ok { ans } else { -1 });
}

struct RollingHashString {
    inner: String,
    hasher: Box<[RollingHasher]>,
}

struct RollingHashSubstring<'a> {
    inner: &'a str,
    hash: Box<[u64]>,
}

impl RollingHashString {
    fn hasher() -> Box<[RollingHasher]> {
        Box::new([
            RollingHasher::new(1007, 1000000007),
            RollingHasher::new(1009, 1000000009),
            RollingHasher::new(1013, 1234567891),
        ])
    }

    fn new() -> RollingHashString {
        RollingHashString {
            inner: String::new(),
            hasher: RollingHashString::hasher(),
        }
    }

    fn from_str(string: &str) -> RollingHashString {
        let mut rs = RollingHashString::new();
        rs.push_str(string);
        rs
    }

    fn push_str(&mut self, string: &str) {
        self.inner.push_str(string);
        for h in self.hasher.iter_mut() {
            std::hash::Hasher::write(h, string.as_bytes());
        }
    }

    fn substr<'a>(&'a self, start: usize, length: usize) -> RollingHashSubstring<'a> {
        RollingHashSubstring {
            inner: &self.inner[start..start + length],
            hash: self
                .hasher
                .iter()
                .map(|h| h.range_hash(start, length))
                .collect::<Vec<_>>()
                .into_boxed_slice(),
        }
    }
}

impl std::fmt::Display for RollingHashString {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.inner.fmt(f)
    }
}

impl<'a> std::fmt::Display for RollingHashSubstring<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.inner.fmt(f)
    }
}

impl std::ops::Deref for RollingHashString {
    type Target = str;

    fn deref(&self) -> &str {
        &self.inner
    }
}

impl<'a> std::ops::Deref for RollingHashSubstring<'a> {
    type Target = str;

    fn deref(&self) -> &str {
        self.inner
    }
}

impl PartialEq for RollingHashString {
    fn eq(&self, other: &RollingHashString) -> bool {
        self.substr(0, self.len()).hash == other.substr(0, other.len()).hash
    }
}

impl<'a> PartialEq<RollingHashSubstring<'a>> for RollingHashString {
    fn eq(&self, other: &RollingHashSubstring<'a>) -> bool {
        self.substr(0, self.len()).hash == other.hash
    }
}

impl<'a> PartialEq<RollingHashString> for RollingHashSubstring<'a> {
    fn eq(&self, other: &RollingHashString) -> bool {
        self.hash == other.substr(0, other.len()).hash
    }
}

impl<'a> PartialEq for RollingHashSubstring<'a> {
    fn eq(&self, other: &RollingHashSubstring<'a>) -> bool {
        self.hash == other.hash
    }
}

impl Eq for RollingHashString {}
impl<'a> Eq for RollingHashSubstring<'a> {}

struct RollingHasher {
    radix: u64,
    modulus: u64,
    hash: Vec<u64>,
    pow: Vec<u64>,
}

impl RollingHasher {
    fn new(radix: u64, modulus: u64) -> RollingHasher {
        RollingHasher {
            radix: radix,
            modulus: modulus,
            hash: vec![0],
            pow: vec![1],
        }
    }

    fn range_hash(&self, start: usize, length: usize) -> u64 {
        let mut h = self.hash[start + length] + self.modulus
            - self.hash[start] * self.pow[length] % self.modulus;
        if h > self.modulus {
            h -= self.modulus;
        }
        h
    }
}

impl std::hash::Hasher for RollingHasher {
    fn finish(&self) -> u64 {
        self.hash[self.hash.len() - 1]
    }

    fn write(&mut self, bytes: &[u8]) {
        let n = self.hash.len();
        self.hash.resize(n + bytes.len(), 0);
        self.pow.resize(n + bytes.len(), 0);
        for i in 0..bytes.len() {
            self.hash[n + i] = (self.hash[n + i - 1] * self.radix + bytes[i] as u64) % self.modulus;
            self.pow[n + i] = self.pow[n + i - 1] * self.radix % self.modulus;
        }
    }
}


Measured memory_bytes: 119156