[SOLVED] need help with second counting algorithm