added code for Uva: 526