parity calcuation