Solution for UVa #12205