Calculating probability with specific conditions