#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let v = read_vec::(); let (n, m, p) = (v[0], v[1], v[2]); let a = read_vec::(); let amax = *a.iter().max().unwrap(); let mut aa = vec![]; for mut num in a { while num % p == 0 { num /= p; } aa.push(num); } // debug!(aa); let aa_max = *aa.iter().max().unwrap(); if aa_max == 1 && amax <= m { println!("-1"); return; } if m == 1 { println!("0"); return; } let mut x = 1; let mut ans = 1; while x * amax <= m { x *= aa_max; ans += 1; } println!("{}", ans); } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }