compute total flips