Let's say you had those values in cells A1:C7, this should do the
trick:

```
=SUMPRODUCT(C1:C7*(A1:A7="D"))+SUMPRODUCT(C1:C7*(B1:B7="D"))-SUMPRODUCT(C1:C7*(A1:A7="D")*(B1:B7="D"))
```

To explain the formula, it is:
(Sum of C where A = "D") + (Sum of C where B = "D") - (Sum of C where both
A = "D" and B = "D")

The reason for the last part is to avoid double counting.