counting rules formula