Solved 2008 Round1A B problem