Apply inclusion–exclusion principle (#719)