Facebook Hackercup: problem #1