Posted by samantha on Monday, December 13, 2010 at 8:23pm.
i don't know about algorithm but the answer is 513.
24