Flag counting