Solve problem 142 using Rust.