added code for Uva: 263