problem five (brute force)