fn getline() -> String{ let mut __ret=String::new(); std::io::stdin().read_line(&mut __ret).ok(); return __ret; } fn nfactorial(x: i64, y: i64) -> i64 { match y { 0 => 1, _ => x * nfactorial(x-1, y-1) } } fn main(){ let s=getline(); let a:Vec<_>=s.trim().split(' ').collect(); let (n, m): (i64, i64) = (a[0].parse().unwrap(), a[1].parse().unwrap()); let mut r = m.pow(n as u32); (1..m).map(|i| { let patterns = (m-i).pow(n as u32); let zeros = nfactorial(m, i) / nfactorial(i, i); if i % 2 == 0 {r += patterns * zeros} else {r -= patterns * zeros}; }).collect::<()>(); print!("{} ", r); }