crossing the river math problem formula