To repeat Sapphire's hint, the first number is the mayor's favorite number, followed by the number of apples growing in Toppletown. You can find out what these are by visiting Soda Junction which is essentially a hint house. The next digit is how many eggs are on the wallpaper at the Waffle House, and "the last three digits are all even - possibly the kind you can find around town." Head back up to the east portion of town and one of those numbers will have made itself visible from the daisies you gave Sapphire. West town will have the other unique number that makes up these last 3 digits.
(For clarification, reaching the Mayor's house is an inconsequential bonus in the game and not necessary at all to achieve the good ending.)