Suppose take a situation
A stack contains $8$ elements
and it is array location $A\left [ 0,....,7 \right ]$
And Stack1 contains
$A\left [ 0 \right ]=x$,$A\left [ 1 \right ]=y$,$A\left [ 2 \right ]=z$
Stack2 contains
$A\left [ 5 \right ]=u$,$A\left [ 6 \right ]=v$, $A\left [ 7 \right ]=w$
Now apply the formula $B)$
According to formula
$n+1-top2+top1=8+1-5+2=6$
Now, that is not correct
right?
because, stack contains only 6 elements