Brill-Noether varieties for pointed curves parametrize linear series on curves with prescribed vanishing at marked points. I will present a formula for the Euler characteristic of the structure sheaf of Brill-Noether varieties for curves with two marked points. The formula recovers the classical Castelnuovo number in the zero-dimensional case, and previous work of Eisenbud-Harris, Pirola, Chan-López-Pflueger-Teixidor in the one-dimensional case. The result follows from a new determinantal formula for the K-theory class of certain degeneracy loci of maps of flag bundles. This is joint work with Dave Anderson and Linda Chen.