An explicit formula for a Bennequin-type invariant for apparent contours